/**************************************************************************************
 * Copyright (c) 2018-2020 ["Peking University Shenzhen Graduate School",
 *   "Peng Cheng Laboratory", and "Guangdong Bohua UHD Innovation Corporation"]
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    This product includes the software uAVS3d developed by
 *    Peking University Shenzhen Graduate School, Peng Cheng Laboratory
 *    and Guangdong Bohua UHD Innovation Corporation.
 * 4. Neither the name of the organizations (Peking University Shenzhen Graduate School,
 *    Peng Cheng Laboratory and Guangdong Bohua UHD Innovation Corporation) nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * For more information, contact us at rgwang@pkusz.edu.cn.
 **************************************************************************************/

#include "define.h"
#include <limits.h>

static tab_s16 tbl_plps[1 << 14] = {
    2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077,
    2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105,
    2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131,
    2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159,
    2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185,
    2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213,
    2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239,
    2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267,
    2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293,
    2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321,
    2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347,
    2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375,
    2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401,
    2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429,
    2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2440, 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455,
    2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483,
    2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509,
    2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2522, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537,
    2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563,
    2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591,
    2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2602, 2603, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 2617,
    2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2630, 2631, 2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2644, 2645,
    2642, 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2656, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671,
    2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699,
    2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725,
    2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753,
    2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2764, 2765, 2764, 2765, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779,
    2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2792, 2793, 2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807,
    2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833,
    2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861,
    2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887,
    2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, 2901, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913, 2914, 2915,
    2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941,
    2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969,
    2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995,
    2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023,
    3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049,
    3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077,
    3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103,
    3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131,
    3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157,
    3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185,
    3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211,
    3210, 3211, 3212, 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, 3225, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239,
    3236, 3237, 3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265,
    3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293,
    3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305, 3304, 3305, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319,
    3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3332, 3333, 3334, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347,
    3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3358, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373,
    3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401,
    3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427,
    3426, 3427, 3428, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, 3437, 3438, 3439, 3440, 3441, 3440, 3441, 3442, 3443, 3444, 3445, 3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455,
    3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478, 3479, 3480, 3481,
    3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 3509,
    3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535,
    3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, 3562, 3563,
    3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3574, 3575, 3574, 3575, 3576, 3577, 3578, 3579, 3580, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589,
    3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617,
    3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643,
    3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671,
    3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697,
    3696, 3697, 3698, 3699, 3700, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, 3723, 3724, 3725,
    3722, 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, 3748, 3749, 3750, 3751,
    3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, 3776, 3777, 3778, 3779,
    2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077,
    2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105,
    2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131,
    2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159,
    2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185,
    2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213,
    2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239,
    2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267,
    2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293,
    2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321,
    2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347,
    2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375,
    2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401,
    2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429,
    2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2440, 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455,
    2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483,
    2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509,
    2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2522, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537,
    2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563,
    2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591,
    2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2602, 2603, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 2617,
    2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2630, 2631, 2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2644, 2645,
    2642, 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2656, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671,
    2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699,
    2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725,
    2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753,
    2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2764, 2765, 2764, 2765, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779,
    2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2792, 2793, 2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807,
    2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833,
    2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861,
    2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887,
    2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, 2901, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913, 2914, 2915,
    2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941,
    2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969,
    2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995,
    2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023,
    3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049,
    3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077,
    3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103,
    3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131,
    3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157,
    3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185,
    3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211,
    3210, 3211, 3212, 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, 3225, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239,
    3236, 3237, 3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265,
    3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293,
    3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305, 3304, 3305, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319,
    3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3332, 3333, 3334, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347,
    3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3358, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373,
    3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401,
    3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427,
    3426, 3427, 3428, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, 3437, 3438, 3439, 3440, 3441, 3440, 3441, 3442, 3443, 3444, 3445, 3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455,
    3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478, 3479, 3480, 3481,
    3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 3509,
    3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535,
    3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, 3562, 3563,
    3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3574, 3575, 3574, 3575, 3576, 3577, 3578, 3579, 3580, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589,
    3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617,
    3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643,
    3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671,
    3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697,
    3696, 3697, 3698, 3699, 3700, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, 3723, 3724, 3725,
    3722, 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, 3748, 3749, 3750, 3751,
    3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, 3776, 3777, 3778, 3779,
    4096, 4097, 4098, 4099, 4100, 4101, 4102, 4103, 4104, 4105, 4106, 4107, 4108, 4109, 4110, 4111, 4112, 4113, 4114, 4115, 4116, 4117, 4118, 4119, 4120, 4121, 4122, 4123, 4124, 4125, 4126, 4127,
    4126, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4140, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157,
    4156, 4157, 4158, 4159, 4160, 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4172, 4173, 4174, 4175, 4176, 4177, 4178, 4179, 4180, 4181, 4182, 4183, 4184, 4185, 4186, 4187,
    4186, 4187, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4217,
    4214, 4215, 4216, 4217, 4218, 4219, 4220, 4221, 4222, 4223, 4224, 4225, 4226, 4227, 4228, 4229, 4230, 4231, 4232, 4233, 4234, 4235, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245,
    4244, 4245, 4246, 4247, 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273, 4274, 4275,
    4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293, 4294, 4295, 4296, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4305,
    4304, 4305, 4306, 4307, 4308, 4309, 4310, 4311, 4312, 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4320, 4321, 4322, 4323, 4324, 4325, 4326, 4327, 4328, 4329, 4330, 4331, 4332, 4333, 4334, 4335,
    4332, 4333, 4334, 4335, 4336, 4337, 4338, 4339, 4340, 4341, 4342, 4343, 4344, 4345, 4346, 4347, 4348, 4349, 4350, 4351, 4352, 4353, 4354, 4355, 4356, 4357, 4358, 4359, 4360, 4361, 4362, 4363,
    4362, 4363, 4364, 4365, 4366, 4367, 4368, 4369, 4370, 4371, 4372, 4373, 4374, 4375, 4376, 4377, 4378, 4379, 4380, 4381, 4382, 4383, 4384, 4385, 4386, 4387, 4388, 4389, 4390, 4391, 4392, 4393,
    4392, 4393, 4394, 4395, 4396, 4397, 4398, 4399, 4400, 4401, 4402, 4403, 4404, 4405, 4406, 4407, 4408, 4409, 4410, 4411, 4412, 4413, 4414, 4415, 4416, 4417, 4418, 4419, 4420, 4421, 4422, 4423,
    4422, 4423, 4424, 4425, 4426, 4427, 4428, 4429, 4430, 4431, 4432, 4433, 4434, 4435, 4436, 4437, 4438, 4439, 4440, 4441, 4442, 4443, 4444, 4445, 4446, 4447, 4448, 4449, 4450, 4451, 4452, 4453,
    4450, 4451, 4452, 4453, 4454, 4455, 4456, 4457, 4458, 4459, 4460, 4461, 4462, 4463, 4464, 4465, 4466, 4467, 4468, 4469, 4470, 4471, 4472, 4473, 4474, 4475, 4476, 4477, 4478, 4479, 4480, 4481,
    4480, 4481, 4482, 4483, 4484, 4485, 4486, 4487, 4488, 4489, 4490, 4491, 4492, 4493, 4494, 4495, 4496, 4497, 4498, 4499, 4500, 4501, 4502, 4503, 4504, 4505, 4506, 4507, 4508, 4509, 4510, 4511,
    4510, 4511, 4512, 4513, 4514, 4515, 4516, 4517, 4518, 4519, 4520, 4521, 4522, 4523, 4524, 4525, 4526, 4527, 4528, 4529, 4530, 4531, 4532, 4533, 4534, 4535, 4536, 4537, 4538, 4539, 4540, 4541,
    4540, 4541, 4542, 4543, 4544, 4545, 4546, 4547, 4548, 4549, 4550, 4551, 4552, 4553, 4554, 4555, 4556, 4557, 4558, 4559, 4560, 4561, 4562, 4563, 4564, 4565, 4566, 4567, 4568, 4569, 4570, 4571,
    4568, 4569, 4570, 4571, 4572, 4573, 4574, 4575, 4576, 4577, 4578, 4579, 4580, 4581, 4582, 4583, 4584, 4585, 4586, 4587, 4588, 4589, 4590, 4591, 4592, 4593, 4594, 4595, 4596, 4597, 4598, 4599,
    4598, 4599, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, 4628, 4629,
    4628, 4629, 4630, 4631, 4632, 4633, 4634, 4635, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4645, 4646, 4647, 4648, 4649, 4650, 4651, 4652, 4653, 4654, 4655, 4656, 4657, 4658, 4659,
    4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, 4680, 4681, 4682, 4683, 4684, 4685, 4686, 4687, 4688, 4689,
    4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717,
    4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4731, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747,
    4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, 4759, 4760, 4761, 4762, 4763, 4764, 4765, 4766, 4767, 4768, 4769, 4770, 4771, 4772, 4773, 4774, 4775, 4776, 4777,
    4776, 4777, 4778, 4779, 4780, 4781, 4782, 4783, 4784, 4785, 4786, 4787, 4788, 4789, 4790, 4791, 4792, 4793, 4794, 4795, 4796, 4797, 4798, 4799, 4800, 4801, 4802, 4803, 4804, 4805, 4806, 4807,
    4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4812, 4813, 4814, 4815, 4816, 4817, 4818, 4819, 4820, 4821, 4822, 4823, 4824, 4825, 4826, 4827, 4828, 4829, 4830, 4831, 4832, 4833, 4834, 4835,
    4834, 4835, 4836, 4837, 4838, 4839, 4840, 4841, 4842, 4843, 4844, 4845, 4846, 4847, 4848, 4849, 4850, 4851, 4852, 4853, 4854, 4855, 4856, 4857, 4858, 4859, 4860, 4861, 4862, 4863, 4864, 4865,
    4864, 4865, 4866, 4867, 4868, 4869, 4870, 4871, 4872, 4873, 4874, 4875, 4876, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, 4887, 4888, 4889, 4890, 4891, 4892, 4893, 4894, 4895,
    4894, 4895, 4896, 4897, 4898, 4899, 4900, 4901, 4902, 4903, 4904, 4905, 4906, 4907, 4908, 4909, 4910, 4911, 4912, 4913, 4914, 4915, 4916, 4917, 4918, 4919, 4920, 4921, 4922, 4923, 4924, 4925,
    4922, 4923, 4924, 4925, 4926, 4927, 4928, 4929, 4930, 4931, 4932, 4933, 4934, 4935, 4936, 4937, 4938, 4939, 4940, 4941, 4942, 4943, 4944, 4945, 4946, 4947, 4948, 4949, 4950, 4951, 4952, 4953,
    4952, 4953, 4954, 4955, 4956, 4957, 4958, 4959, 4960, 4961, 4962, 4963, 4964, 4965, 4966, 4967, 4968, 4969, 4970, 4971, 4972, 4973, 4974, 4975, 4976, 4977, 4978, 4979, 4980, 4981, 4982, 4983,
    4982, 4983, 4984, 4985, 4986, 4987, 4988, 4989, 4990, 4991, 4992, 4993, 4994, 4995, 4996, 4997, 4998, 4999, 5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013,
    5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 5032, 5033, 5034, 5035, 5036, 5037, 5038, 5039, 5040, 5041, 5042, 5043,
    5040, 5041, 5042, 5043, 5044, 5045, 5046, 5047, 5048, 5049, 5050, 5051, 5052, 5053, 5054, 5055, 5056, 5057, 5058, 5059, 5060, 5061, 5062, 5063, 5064, 5065, 5066, 5067, 5068, 5069, 5070, 5071,
    5070, 5071, 5072, 5073, 5074, 5075, 5076, 5077, 5078, 5079, 5080, 5081, 5082, 5083, 5084, 5085, 5086, 5087, 5088, 5089, 5090, 5091, 5092, 5093, 5094, 5095, 5096, 5097, 5098, 5099, 5100, 5101,
    5100, 5101, 5102, 5103, 5104, 5105, 5106, 5107, 5108, 5109, 5110, 5111, 5112, 5113, 5114, 5115, 5116, 5117, 5118, 5119, 5120, 5121, 5122, 5123, 5124, 5125, 5126, 5127, 5128, 5129, 5130, 5131,
    5130, 5131, 5132, 5133, 5134, 5135, 5136, 5137, 5138, 5139, 5140, 5141, 5142, 5143, 5144, 5145, 5146, 5147, 5148, 5149, 5150, 5151, 5152, 5153, 5154, 5155, 5156, 5157, 5158, 5159, 5160, 5161,
    5158, 5159, 5160, 5161, 5162, 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5170, 5171, 5172, 5173, 5174, 5175, 5176, 5177, 5178, 5179, 5180, 5181, 5182, 5183, 5184, 5185, 5186, 5187, 5188, 5189,
    5188, 5189, 5190, 5191, 5192, 5193, 5194, 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, 5203, 5204, 5205, 5206, 5207, 5208, 5209, 5210, 5211, 5212, 5213, 5214, 5215, 5216, 5217, 5218, 5219,
    5218, 5219, 5220, 5221, 5222, 5223, 5224, 5225, 5226, 5227, 5228, 5229, 5230, 5231, 5232, 5233, 5234, 5235, 5236, 5237, 5238, 5239, 5240, 5241, 5242, 5243, 5244, 5245, 5246, 5247, 5248, 5249,
    5248, 5249, 5250, 5251, 5252, 5253, 5254, 5255, 5256, 5257, 5258, 5259, 5260, 5261, 5262, 5263, 5264, 5265, 5266, 5267, 5268, 5269, 5270, 5271, 5272, 5273, 5274, 5275, 5276, 5277, 5278, 5279,
    5276, 5277, 5278, 5279, 5280, 5281, 5282, 5283, 5284, 5285, 5286, 5287, 5288, 5289, 5290, 5291, 5292, 5293, 5294, 5295, 5296, 5297, 5298, 5299, 5300, 5301, 5302, 5303, 5304, 5305, 5306, 5307,
    5306, 5307, 5308, 5309, 5310, 5311, 5312, 5313, 5314, 5315, 5316, 5317, 5318, 5319, 5320, 5321, 5322, 5323, 5324, 5325, 5326, 5327, 5328, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 5336, 5337,
    5336, 5337, 5338, 5339, 5340, 5341, 5342, 5343, 5344, 5345, 5346, 5347, 5348, 5349, 5350, 5351, 5352, 5353, 5354, 5355, 5356, 5357, 5358, 5359, 5360, 5361, 5362, 5363, 5364, 5365, 5366, 5367,
    5366, 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, 5383, 5384, 5385, 5386, 5387, 5388, 5389, 5390, 5391, 5392, 5393, 5394, 5395, 5396, 5397,
    5394, 5395, 5396, 5397, 5398, 5399, 5400, 5401, 5402, 5403, 5404, 5405, 5406, 5407, 5408, 5409, 5410, 5411, 5412, 5413, 5414, 5415, 5416, 5417, 5418, 5419, 5420, 5421, 5422, 5423, 5424, 5425,
    5424, 5425, 5426, 5427, 5428, 5429, 5430, 5431, 5432, 5433, 5434, 5435, 5436, 5437, 5438, 5439, 5440, 5441, 5442, 5443, 5444, 5445, 5446, 5447, 5448, 5449, 5450, 5451, 5452, 5453, 5454, 5455,
    5454, 5455, 5456, 5457, 5458, 5459, 5460, 5461, 5462, 5463, 5464, 5465, 5466, 5467, 5468, 5469, 5470, 5471, 5472, 5473, 5474, 5475, 5476, 5477, 5478, 5479, 5480, 5481, 5482, 5483, 5484, 5485,
    5484, 5485, 5486, 5487, 5488, 5489, 5490, 5491, 5492, 5493, 5494, 5495, 5496, 5497, 5498, 5499, 5500, 5501, 5502, 5503, 5504, 5505, 5506, 5507, 5508, 5509, 5510, 5511, 5512, 5513, 5514, 5515,
    5512, 5513, 5514, 5515, 5516, 5517, 5518, 5519, 5520, 5521, 5522, 5523, 5524, 5525, 5526, 5527, 5528, 5529, 5530, 5531, 5532, 5533, 5534, 5535, 5536, 5537, 5538, 5539, 5540, 5541, 5542, 5543,
    5542, 5543, 5544, 5545, 5546, 5547, 5548, 5549, 5550, 5551, 5552, 5553, 5554, 5555, 5556, 5557, 5558, 5559, 5560, 5561, 5562, 5563, 5564, 5565, 5566, 5567, 5568, 5569, 5570, 5571, 5572, 5573,
    5572, 5573, 5574, 5575, 5576, 5577, 5578, 5579, 5580, 5581, 5582, 5583, 5584, 5585, 5586, 5587, 5588, 5589, 5590, 5591, 5592, 5593, 5594, 5595, 5596, 5597, 5598, 5599, 5600, 5601, 5602, 5603,
    5602, 5603, 5604, 5605, 5606, 5607, 5608, 5609, 5610, 5611, 5612, 5613, 5614, 5615, 5616, 5617, 5618, 5619, 5620, 5621, 5622, 5623, 5624, 5625, 5626, 5627, 5628, 5629, 5630, 5631, 5632, 5633,
    5630, 5631, 5632, 5633, 5634, 5635, 5636, 5637, 5638, 5639, 5640, 5641, 5642, 5643, 5644, 5645, 5646, 5647, 5648, 5649, 5650, 5651, 5652, 5653, 5654, 5655, 5656, 5657, 5658, 5659, 5660, 5661,
    5660, 5661, 5662, 5663, 5664, 5665, 5666, 5667, 5668, 5669, 5670, 5671, 5672, 5673, 5674, 5675, 5676, 5677, 5678, 5679, 5680, 5681, 5682, 5683, 5684, 5685, 5686, 5687, 5688, 5689, 5690, 5691,
    5690, 5691, 5692, 5693, 5694, 5695, 5696, 5697, 5698, 5699, 5700, 5701, 5702, 5703, 5704, 5705, 5706, 5707, 5708, 5709, 5710, 5711, 5712, 5713, 5714, 5715, 5716, 5717, 5718, 5719, 5720, 5721,
    5720, 5721, 5722, 5723, 5724, 5725, 5726, 5727, 5728, 5729, 5730, 5731, 5732, 5733, 5734, 5735, 5736, 5737, 5738, 5739, 5740, 5741, 5742, 5743, 5744, 5745, 5746, 5747, 5748, 5749, 5750, 5751,
    5748, 5749, 5750, 5751, 5752, 5753, 5754, 5755, 5756, 5757, 5758, 5759, 5760, 5761, 5762, 5763, 5764, 5765, 5766, 5767, 5768, 5769, 5770, 5771, 5772, 5773, 5774, 5775, 5776, 5777, 5778, 5779,
    5778, 5779, 5780, 5781, 5782, 5783, 5784, 5785, 5786, 5787, 5788, 5789, 5790, 5791, 5792, 5793, 5794, 5795, 5796, 5797, 5798, 5799, 5800, 5801, 5802, 5803, 5804, 5805, 5806, 5807, 5808, 5809,
    5808, 5809, 5810, 5811, 5812, 5813, 5814, 5815, 5816, 5817, 5818, 5819, 5820, 5821, 5822, 5823, 5824, 5825, 5826, 5827, 5828, 5829, 5830, 5831, 5832, 5833, 5834, 5835, 5836, 5837, 5838, 5839,
    5838, 5839, 5840, 5841, 5842, 5843, 5844, 5845, 5846, 5847, 5848, 5849, 5850, 5851, 5852, 5853, 5854, 5855, 5856, 5857, 5858, 5859, 5860, 5861, 5862, 5863, 5864, 5865, 5866, 5867, 5868, 5869,
    5866, 5867, 5868, 5869, 5870, 5871, 5872, 5873, 5874, 5875, 5876, 5877, 5878, 5879, 5880, 5881, 5882, 5883, 5884, 5885, 5886, 5887, 5888, 5889, 5890, 5891, 5892, 5893, 5894, 5895, 5896, 5897,
    5896, 5897, 5898, 5899, 5900, 5901, 5902, 5903, 5904, 5905, 5906, 5907, 5908, 5909, 5910, 5911, 5912, 5913, 5914, 5915, 5916, 5917, 5918, 5919, 5920, 5921, 5922, 5923, 5924, 5925, 5926, 5927,
    5926, 5927, 5928, 5929, 5930, 5931, 5932, 5933, 5934, 5935, 5936, 5937, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5945, 5946, 5947, 5948, 5949, 5950, 5951, 5952, 5953, 5954, 5955, 5956, 5957,
    5956, 5957, 5958, 5959, 5960, 5961, 5962, 5963, 5964, 5965, 5966, 5967, 5968, 5969, 5970, 5971, 5972, 5973, 5974, 5975, 5976, 5977, 5978, 5979, 5980, 5981, 5982, 5983, 5984, 5985, 5986, 5987,
    6144, 6145, 6146, 6147, 6148, 6149, 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, 6158, 6159, 6160, 6161, 6162, 6163, 6164, 6165, 6166, 6167, 6168, 6169, 6170, 6171, 6172, 6173, 6174, 6175,
    6176, 6177, 6178, 6179, 6180, 6181, 6182, 6183, 6184, 6185, 6186, 6187, 6188, 6189, 6190, 6191, 6192, 6193, 6194, 6195, 6196, 6197, 6198, 6199, 6200, 6201, 6202, 6203, 6204, 6205, 6206, 6207,
    6206, 6207, 6208, 6209, 6210, 6211, 6212, 6213, 6214, 6215, 6216, 6217, 6218, 6219, 6220, 6221, 6222, 6223, 6224, 6225, 6226, 6227, 6228, 6229, 6230, 6231, 6232, 6233, 6234, 6235, 6236, 6237,
    6238, 6239, 6240, 6241, 6242, 6243, 6244, 6245, 6246, 6247, 6248, 6249, 6250, 6251, 6252, 6253, 6254, 6255, 6256, 6257, 6258, 6259, 6260, 6261, 6262, 6263, 6264, 6265, 6266, 6267, 6268, 6269,
    6268, 6269, 6270, 6271, 6272, 6273, 6274, 6275, 6276, 6277, 6278, 6279, 6280, 6281, 6282, 6283, 6284, 6285, 6286, 6287, 6288, 6289, 6290, 6291, 6292, 6293, 6294, 6295, 6296, 6297, 6298, 6299,
    6300, 6301, 6302, 6303, 6304, 6305, 6306, 6307, 6308, 6309, 6310, 6311, 6312, 6313, 6314, 6315, 6316, 6317, 6318, 6319, 6320, 6321, 6322, 6323, 6324, 6325, 6326, 6327, 6328, 6329, 6330, 6331,
    6330, 6331, 6332, 6333, 6334, 6335, 6336, 6337, 6338, 6339, 6340, 6341, 6342, 6343, 6344, 6345, 6346, 6347, 6348, 6349, 6350, 6351, 6352, 6353, 6354, 6355, 6356, 6357, 6358, 6359, 6360, 6361,
    6362, 6363, 6364, 6365, 6366, 6367, 6368, 6369, 6370, 6371, 6372, 6373, 6374, 6375, 6376, 6377, 6378, 6379, 6380, 6381, 6382, 6383, 6384, 6385, 6386, 6387, 6388, 6389, 6390, 6391, 6392, 6393,
    6390, 6391, 6392, 6393, 6394, 6395, 6396, 6397, 6398, 6399, 6400, 6401, 6402, 6403, 6404, 6405, 6406, 6407, 6408, 6409, 6410, 6411, 6412, 6413, 6414, 6415, 6416, 6417, 6418, 6419, 6420, 6421,
    6422, 6423, 6424, 6425, 6426, 6427, 6428, 6429, 6430, 6431, 6432, 6433, 6434, 6435, 6436, 6437, 6438, 6439, 6440, 6441, 6442, 6443, 6444, 6445, 6446, 6447, 6448, 6449, 6450, 6451, 6452, 6453,
    6452, 6453, 6454, 6455, 6456, 6457, 6458, 6459, 6460, 6461, 6462, 6463, 6464, 6465, 6466, 6467, 6468, 6469, 6470, 6471, 6472, 6473, 6474, 6475, 6476, 6477, 6478, 6479, 6480, 6481, 6482, 6483,
    6484, 6485, 6486, 6487, 6488, 6489, 6490, 6491, 6492, 6493, 6494, 6495, 6496, 6497, 6498, 6499, 6500, 6501, 6502, 6503, 6504, 6505, 6506, 6507, 6508, 6509, 6510, 6511, 6512, 6513, 6514, 6515,
    6514, 6515, 6516, 6517, 6518, 6519, 6520, 6521, 6522, 6523, 6524, 6525, 6526, 6527, 6528, 6529, 6530, 6531, 6532, 6533, 6534, 6535, 6536, 6537, 6538, 6539, 6540, 6541, 6542, 6543, 6544, 6545,
    6546, 6547, 6548, 6549, 6550, 6551, 6552, 6553, 6554, 6555, 6556, 6557, 6558, 6559, 6560, 6561, 6562, 6563, 6564, 6565, 6566, 6567, 6568, 6569, 6570, 6571, 6572, 6573, 6574, 6575, 6576, 6577,
    6576, 6577, 6578, 6579, 6580, 6581, 6582, 6583, 6584, 6585, 6586, 6587, 6588, 6589, 6590, 6591, 6592, 6593, 6594, 6595, 6596, 6597, 6598, 6599, 6600, 6601, 6602, 6603, 6604, 6605, 6606, 6607,
    6608, 6609, 6610, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 6622, 6623, 6624, 6625, 6626, 6627, 6628, 6629, 6630, 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639,
    6636, 6637, 6638, 6639, 6640, 6641, 6642, 6643, 6644, 6645, 6646, 6647, 6648, 6649, 6650, 6651, 6652, 6653, 6654, 6655, 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667,
    6668, 6669, 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678, 6679, 6680, 6681, 6682, 6683, 6684, 6685, 6686, 6687, 6688, 6689, 6690, 6691, 6692, 6693, 6694, 6695, 6696, 6697, 6698, 6699,
    6698, 6699, 6700, 6701, 6702, 6703, 6704, 6705, 6706, 6707, 6708, 6709, 6710, 6711, 6712, 6713, 6714, 6715, 6716, 6717, 6718, 6719, 6720, 6721, 6722, 6723, 6724, 6725, 6726, 6727, 6728, 6729,
    6730, 6731, 6732, 6733, 6734, 6735, 6736, 6737, 6738, 6739, 6740, 6741, 6742, 6743, 6744, 6745, 6746, 6747, 6748, 6749, 6750, 6751, 6752, 6753, 6754, 6755, 6756, 6757, 6758, 6759, 6760, 6761,
    6760, 6761, 6762, 6763, 6764, 6765, 6766, 6767, 6768, 6769, 6770, 6771, 6772, 6773, 6774, 6775, 6776, 6777, 6778, 6779, 6780, 6781, 6782, 6783, 6784, 6785, 6786, 6787, 6788, 6789, 6790, 6791,
    6792, 6793, 6794, 6795, 6796, 6797, 6798, 6799, 6800, 6801, 6802, 6803, 6804, 6805, 6806, 6807, 6808, 6809, 6810, 6811, 6812, 6813, 6814, 6815, 6816, 6817, 6818, 6819, 6820, 6821, 6822, 6823,
    6822, 6823, 6824, 6825, 6826, 6827, 6828, 6829, 6830, 6831, 6832, 6833, 6834, 6835, 6836, 6837, 6838, 6839, 6840, 6841, 6842, 6843, 6844, 6845, 6846, 6847, 6848, 6849, 6850, 6851, 6852, 6853,
    6854, 6855, 6856, 6857, 6858, 6859, 6860, 6861, 6862, 6863, 6864, 6865, 6866, 6867, 6868, 6869, 6870, 6871, 6872, 6873, 6874, 6875, 6876, 6877, 6878, 6879, 6880, 6881, 6882, 6883, 6884, 6885,
    6882, 6883, 6884, 6885, 6886, 6887, 6888, 6889, 6890, 6891, 6892, 6893, 6894, 6895, 6896, 6897, 6898, 6899, 6900, 6901, 6902, 6903, 6904, 6905, 6906, 6907, 6908, 6909, 6910, 6911, 6912, 6913,
    6914, 6915, 6916, 6917, 6918, 6919, 6920, 6921, 6922, 6923, 6924, 6925, 6926, 6927, 6928, 6929, 6930, 6931, 6932, 6933, 6934, 6935, 6936, 6937, 6938, 6939, 6940, 6941, 6942, 6943, 6944, 6945,
    6944, 6945, 6946, 6947, 6948, 6949, 6950, 6951, 6952, 6953, 6954, 6955, 6956, 6957, 6958, 6959, 6960, 6961, 6962, 6963, 6964, 6965, 6966, 6967, 6968, 6969, 6970, 6971, 6972, 6973, 6974, 6975,
    6976, 6977, 6978, 6979, 6980, 6981, 6982, 6983, 6984, 6985, 6986, 6987, 6988, 6989, 6990, 6991, 6992, 6993, 6994, 6995, 6996, 6997, 6998, 6999, 7000, 7001, 7002, 7003, 7004, 7005, 7006, 7007,
    7006, 7007, 7008, 7009, 7010, 7011, 7012, 7013, 7014, 7015, 7016, 7017, 7018, 7019, 7020, 7021, 7022, 7023, 7024, 7025, 7026, 7027, 7028, 7029, 7030, 7031, 7032, 7033, 7034, 7035, 7036, 7037,
    7038, 7039, 7040, 7041, 7042, 7043, 7044, 7045, 7046, 7047, 7048, 7049, 7050, 7051, 7052, 7053, 7054, 7055, 7056, 7057, 7058, 7059, 7060, 7061, 7062, 7063, 7064, 7065, 7066, 7067, 7068, 7069,
    7068, 7069, 7070, 7071, 7072, 7073, 7074, 7075, 7076, 7077, 7078, 7079, 7080, 7081, 7082, 7083, 7084, 7085, 7086, 7087, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, 7096, 7097, 7098, 7099,
    7100, 7101, 7102, 7103, 7104, 7105, 7106, 7107, 7108, 7109, 7110, 7111, 7112, 7113, 7114, 7115, 7116, 7117, 7118, 7119, 7120, 7121, 7122, 7123, 7124, 7125, 7126, 7127, 7128, 7129, 7130, 7131,
    7128, 7129, 7130, 7131, 7132, 7133, 7134, 7135, 7136, 7137, 7138, 7139, 7140, 7141, 7142, 7143, 7144, 7145, 7146, 7147, 7148, 7149, 7150, 7151, 7152, 7153, 7154, 7155, 7156, 7157, 7158, 7159,
    7160, 7161, 7162, 7163, 7164, 7165, 7166, 7167, 7168, 7169, 7170, 7171, 7172, 7173, 7174, 7175, 7176, 7177, 7178, 7179, 7180, 7181, 7182, 7183, 7184, 7185, 7186, 7187, 7188, 7189, 7190, 7191,
    7190, 7191, 7192, 7193, 7194, 7195, 7196, 7197, 7198, 7199, 7200, 7201, 7202, 7203, 7204, 7205, 7206, 7207, 7208, 7209, 7210, 7211, 7212, 7213, 7214, 7215, 7216, 7217, 7218, 7219, 7220, 7221,
    7222, 7223, 7224, 7225, 7226, 7227, 7228, 7229, 7230, 7231, 7232, 7233, 7234, 7235, 7236, 7237, 7238, 7239, 7240, 7241, 7242, 7243, 7244, 7245, 7246, 7247, 7248, 7249, 7250, 7251, 7252, 7253,
    7252, 7253, 7254, 7255, 7256, 7257, 7258, 7259, 7260, 7261, 7262, 7263, 7264, 7265, 7266, 7267, 7268, 7269, 7270, 7271, 7272, 7273, 7274, 7275, 7276, 7277, 7278, 7279, 7280, 7281, 7282, 7283,
    7284, 7285, 7286, 7287, 7288, 7289, 7290, 7291, 7292, 7293, 7294, 7295, 7296, 7297, 7298, 7299, 7300, 7301, 7302, 7303, 7304, 7305, 7306, 7307, 7308, 7309, 7310, 7311, 7312, 7313, 7314, 7315,
    7314, 7315, 7316, 7317, 7318, 7319, 7320, 7321, 7322, 7323, 7324, 7325, 7326, 7327, 7328, 7329, 7330, 7331, 7332, 7333, 7334, 7335, 7336, 7337, 7338, 7339, 7340, 7341, 7342, 7343, 7344, 7345,
    7346, 7347, 7348, 7349, 7350, 7351, 7352, 7353, 7354, 7355, 7356, 7357, 7358, 7359, 7360, 7361, 7362, 7363, 7364, 7365, 7366, 7367, 7368, 7369, 7370, 7371, 7372, 7373, 7374, 7375, 7376, 7377,
    7374, 7375, 7376, 7377, 7378, 7379, 7380, 7381, 7382, 7383, 7384, 7385, 7386, 7387, 7388, 7389, 7390, 7391, 7392, 7393, 7394, 7395, 7396, 7397, 7398, 7399, 7400, 7401, 7402, 7403, 7404, 7405,
    7406, 7407, 7408, 7409, 7410, 7411, 7412, 7413, 7414, 7415, 7416, 7417, 7418, 7419, 7420, 7421, 7422, 7423, 7424, 7425, 7426, 7427, 7428, 7429, 7430, 7431, 7432, 7433, 7434, 7435, 7436, 7437,
    7436, 7437, 7438, 7439, 7440, 7441, 7442, 7443, 7444, 7445, 7446, 7447, 7448, 7449, 7450, 7451, 7452, 7453, 7454, 7455, 7456, 7457, 7458, 7459, 7460, 7461, 7462, 7463, 7464, 7465, 7466, 7467,
    7468, 7469, 7470, 7471, 7472, 7473, 7474, 7475, 7476, 7477, 7478, 7479, 7480, 7481, 7482, 7483, 7484, 7485, 7486, 7487, 7488, 7489, 7490, 7491, 7492, 7493, 7494, 7495, 7496, 7497, 7498, 7499,
    7498, 7499, 7500, 7501, 7502, 7503, 7504, 7505, 7506, 7507, 7508, 7509, 7510, 7511, 7512, 7513, 7514, 7515, 7516, 7517, 7518, 7519, 7520, 7521, 7522, 7523, 7524, 7525, 7526, 7527, 7528, 7529,
    7530, 7531, 7532, 7533, 7534, 7535, 7536, 7537, 7538, 7539, 7540, 7541, 7542, 7543, 7544, 7545, 7546, 7547, 7548, 7549, 7550, 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558, 7559, 7560, 7561,
    7560, 7561, 7562, 7563, 7564, 7565, 7566, 7567, 7568, 7569, 7570, 7571, 7572, 7573, 7574, 7575, 7576, 7577, 7578, 7579, 7580, 7581, 7582, 7583, 7584, 7585, 7586, 7587, 7588, 7589, 7590, 7591,
    7592, 7593, 7594, 7595, 7596, 7597, 7598, 7599, 7600, 7601, 7602, 7603, 7604, 7605, 7606, 7607, 7608, 7609, 7610, 7611, 7612, 7613, 7614, 7615, 7616, 7617, 7618, 7619, 7620, 7621, 7622, 7623,
    7620, 7621, 7622, 7623, 7624, 7625, 7626, 7627, 7628, 7629, 7630, 7631, 7632, 7633, 7634, 7635, 7636, 7637, 7638, 7639, 7640, 7641, 7642, 7643, 7644, 7645, 7646, 7647, 7648, 7649, 7650, 7651,
    7652, 7653, 7654, 7655, 7656, 7657, 7658, 7659, 7660, 7661, 7662, 7663, 7664, 7665, 7666, 7667, 7668, 7669, 7670, 7671, 7672, 7673, 7674, 7675, 7676, 7677, 7678, 7679, 7680, 7681, 7682, 7683,
    7682, 7683, 7684, 7685, 7686, 7687, 7688, 7689, 7690, 7691, 7692, 7693, 7694, 7695, 7696, 7697, 7698, 7699, 7700, 7701, 7702, 7703, 7704, 7705, 7706, 7707, 7708, 7709, 7710, 7711, 7712, 7713,
    7714, 7715, 7716, 7717, 7718, 7719, 7720, 7721, 7722, 7723, 7724, 7725, 7726, 7727, 7728, 7729, 7730, 7731, 7732, 7733, 7734, 7735, 7736, 7737, 7738, 7739, 7740, 7741, 7742, 7743, 7744, 7745,
    7744, 7745, 7746, 7747, 7748, 7749, 7750, 7751, 7752, 7753, 7754, 7755, 7756, 7757, 7758, 7759, 7760, 7761, 7762, 7763, 7764, 7765, 7766, 7767, 7768, 7769, 7770, 7771, 7772, 7773, 7774, 7775,
    7776, 7777, 7778, 7779, 7780, 7781, 7782, 7783, 7784, 7785, 7786, 7787, 7788, 7789, 7790, 7791, 7792, 7793, 7794, 7795, 7796, 7797, 7798, 7799, 7800, 7801, 7802, 7803, 7804, 7805, 7806, 7807,
    7806, 7807, 7808, 7809, 7810, 7811, 7812, 7813, 7814, 7815, 7816, 7817, 7818, 7819, 7820, 7821, 7822, 7823, 7824, 7825, 7826, 7827, 7828, 7829, 7830, 7831, 7832, 7833, 7834, 7835, 7836, 7837,
    7838, 7839, 7840, 7841, 7842, 7843, 7844, 7845, 7846, 7847, 7848, 7849, 7850, 7851, 7852, 7853, 7854, 7855, 7856, 7857, 7858, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7866, 7867, 7868, 7869,
    7866, 7867, 7868, 7869, 7870, 7871, 7872, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, 7884, 7885, 7886, 7887, 7888, 7889, 7890, 7891, 7892, 7893, 7894, 7895, 7896, 7897,
    7898, 7899, 7900, 7901, 7902, 7903, 7904, 7905, 7906, 7907, 7908, 7909, 7910, 7911, 7912, 7913, 7914, 7915, 7916, 7917, 7918, 7919, 7920, 7921, 7922, 7923, 7924, 7925, 7926, 7927, 7928, 7929,
    7928, 7929, 7930, 7931, 7932, 7933, 7934, 7935, 7936, 7937, 7938, 7939, 7940, 7941, 7942, 7943, 7944, 7945, 7946, 7947, 7948, 7949, 7950, 7951, 7952, 7953, 7954, 7955, 7956, 7957, 7958, 7959,
    7960, 7961, 7962, 7963, 7964, 7965, 7966, 7967, 7968, 7969, 7970, 7971, 7972, 7973, 7974, 7975, 7976, 7977, 7978, 7979, 7980, 7981, 7982, 7983, 7984, 7985, 7986, 7987, 7988, 7989, 7990, 7991,
    7990, 7991, 7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999, 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009, 8010, 8011, 8012, 8013, 8014, 8015, 8016, 8017, 8018, 8019, 8020, 8021,
    8022, 8023, 8024, 8025, 8026, 8027, 8028, 8029, 8030, 8031, 8032, 8033, 8034, 8035, 8036, 8037, 8038, 8039, 8040, 8041, 8042, 8043, 8044, 8045, 8046, 8047, 8048, 8049, 8050, 8051, 8052, 8053,
    8052, 8053, 8054, 8055, 8056, 8057, 8058, 8059, 8060, 8061, 8062, 8063, 8064, 8065, 8066, 8067, 8068, 8069, 8070, 8071, 8072, 8073, 8074, 8075, 8076, 8077, 8078, 8079, 8080, 8081, 8082, 8083,
    8084, 8085, 8086, 8087, 8088, 8089, 8090, 8091, 8092, 8093, 8094, 8095, 8096, 8097, 8098, 8099, 8100, 8101, 8102, 8103, 8104, 8105, 8106, 8107, 8108, 8109, 8110, 8111, 8112, 8113, 8114, 8115,
    2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473,
    2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505,
    2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537,
    2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569,
    2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601,
    2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2632, 2633,
    2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665,
    2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697,
    2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729,
    2730, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761,
    2762, 2763, 2764, 2765, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793,
    2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825,
    2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857,
    2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887, 2888, 2889,
    2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921,
    2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953,
    2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985,
    2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017,
    3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049,
    3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081,
    3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113,
    3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3144, 3145,
    3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177,
    3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209,
    3210, 3211, 3212, 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239, 3240, 3241,
    3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273,
    3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305,
    3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3334, 3335, 3336, 3337,
    3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369,
    3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401,
    3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427, 3428, 3429, 3430, 3431, 3432, 3433,
    3434, 3435, 3436, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3445, 3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3463, 3464, 3465,
    3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3496, 3497,
    3498, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529,
    3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561,
    3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3574, 3575, 3576, 3577, 3578, 3579, 3580, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593,
    3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625,
    3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657,
    3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689,
    3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 3699, 3700, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721,
    3722, 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, 3748, 3749, 3750, 3751, 3752, 3753,
    3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785,
    3786, 3787, 3788, 3789, 3790, 3791, 3792, 3793, 3794, 3795, 3796, 3797, 3798, 3799, 3800, 3801, 3802, 3803, 3804, 3805, 3806, 3807, 3808, 3809, 3810, 3811, 3812, 3813, 3814, 3815, 3816, 3817,
    3818, 3819, 3820, 3821, 3822, 3823, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3844, 3845, 3846, 3847, 3848, 3849,
    3850, 3851, 3852, 3853, 3854, 3855, 3856, 3857, 3858, 3859, 3860, 3861, 3862, 3863, 3864, 3865, 3866, 3867, 3868, 3869, 3870, 3871, 3872, 3873, 3874, 3875, 3876, 3877, 3878, 3879, 3880, 3881,
    3882, 3883, 3884, 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 3894, 3895, 3896, 3897, 3898, 3899, 3900, 3901, 3902, 3903, 3904, 3905, 3906, 3907, 3908, 3909, 3910, 3911, 3912, 3913,
    3914, 3915, 3916, 3917, 3918, 3919, 3920, 3921, 3922, 3923, 3924, 3925, 3926, 3927, 3928, 3929, 3930, 3931, 3932, 3933, 3934, 3935, 3936, 3937, 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945,
    3946, 3947, 3948, 3949, 3950, 3951, 3952, 3953, 3954, 3955, 3956, 3957, 3958, 3959, 3960, 3961, 3962, 3963, 3964, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3973, 3974, 3975, 3976, 3977,
    3978, 3979, 3980, 3981, 3982, 3983, 3984, 3985, 3986, 3987, 3988, 3989, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009,
    4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038, 4039, 4040, 4041,
    4042, 4043, 4044, 4045, 4046, 4047, 4048, 4049, 4050, 4051, 4052, 4053, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 4070, 4071, 4072, 4073,
    4074, 4075, 4076, 4077, 4078, 4079, 4080, 4081, 4082, 4083, 4084, 4085, 4086, 4087, 4088, 4089, 4090, 4091, 4092, 4093, 4094, 4095, 4095, 4094, 4093, 4092, 4091, 4090, 4089, 4088, 4087, 4086,
    4085, 4084, 4083, 4082, 4081, 4080, 4079, 4078, 4077, 4076, 4075, 4074, 4073, 4072, 4071, 4070, 4069, 4068, 4067, 4066, 4065, 4064, 4063, 4062, 4061, 4060, 4059, 4058, 4057, 4056, 4055, 4054,
    4053, 4052, 4051, 4050, 4049, 4048, 4047, 4046, 4045, 4044, 4043, 4042, 4041, 4040, 4039, 4038, 4037, 4036, 4035, 4034, 4033, 4032, 4031, 4030, 4029, 4028, 4027, 4026, 4025, 4024, 4023, 4022,
    4021, 4020, 4019, 4018, 4017, 4016, 4015, 4014, 4013, 4012, 4011, 4010, 4009, 4008, 4007, 4006, 4005, 4004, 4003, 4002, 4001, 4000, 3999, 3998, 3997, 3996, 3995, 3994, 3993, 3992, 3991, 3990,
    3989, 3988, 3987, 3986, 3985, 3984, 3983, 3982, 3981, 3980, 3979, 3978, 3977, 3976, 3975, 3974, 3973, 3972, 3971, 3970, 3969, 3968, 3967, 3966, 3965, 3964, 3963, 3962, 3961, 3960, 3959, 3958,
    3957, 3956, 3955, 3954, 3953, 3952, 3951, 3950, 3949, 3948, 3947, 3946, 3945, 3944, 3943, 3942, 3941, 3940, 3939, 3938, 3937, 3936, 3935, 3934, 3933, 3932, 3931, 3930, 3929, 3928, 3927, 3926,
    3925, 3924, 3923, 3922, 3921, 3920, 3919, 3918, 3917, 3916, 3915, 3914, 3913, 3912, 3911, 3910, 3909, 3908, 3907, 3906, 3905, 3904, 3903, 3902, 3901, 3900, 3899, 3898, 3897, 3896, 3895, 3894,
    3893, 3892, 3891, 3890, 3889, 3888, 3887, 3886, 3885, 3884, 3883, 3882, 3881, 3880, 3879, 3878, 3877, 3876, 3875, 3874, 3873, 3872, 3871, 3870, 3869, 3868, 3867, 3866, 3865, 3864, 3863, 3862,
    3861, 3860, 3859, 3858, 3857, 3856, 3855, 3854, 3853, 3852, 3851, 3850, 3849, 3848, 3847, 3846, 3845, 3844, 3843, 3842, 3841, 3840, 3839, 3838, 3837, 3836, 3835, 3834, 3833, 3832, 3831, 3830,
    3829, 3828, 3827, 3826, 3825, 3824, 3823, 3822, 3821, 3820, 3819, 3818, 3817, 3816, 3815, 3814, 3813, 3812, 3811, 3810, 3809, 3808, 3807, 3806, 3805, 3804, 3803, 3802, 3801, 3800, 3799, 3798,
    3797, 3796, 3795, 3794, 3793, 3792, 3791, 3790, 3789, 3788, 3787, 3786, 3785, 3784, 3783, 3782, 3781, 3780, 3779, 3778, 3777, 3776, 3775, 3774, 3773, 3772, 3771, 3770, 3769, 3768, 3767, 3766,
    3765, 3764, 3763, 3762, 3761, 3760, 3759, 3758, 3757, 3756, 3755, 3754, 3753, 3752, 3751, 3750, 3749, 3748, 3747, 3746, 3745, 3744, 3743, 3742, 3741, 3740, 3739, 3738, 3737, 3736, 3735, 3734,
    3733, 3732, 3731, 3730, 3729, 3728, 3727, 3726, 3725, 3724, 3723, 3722, 3721, 3720, 3719, 3718, 3717, 3716, 3715, 3714, 3713, 3712, 3711, 3710, 3709, 3708, 3707, 3706, 3705, 3704, 3703, 3702,
    4490, 4491, 4492, 4493, 4494, 4495, 4496, 4497, 4498, 4499, 4500, 4501, 4502, 4503, 4504, 4505, 4506, 4507, 4508, 4509, 4510, 4511, 4512, 4513, 4514, 4515, 4516, 4517, 4518, 4519, 4520, 4521,
    4522, 4523, 4524, 4525, 4526, 4527, 4528, 4529, 4530, 4531, 4532, 4533, 4534, 4535, 4536, 4537, 4538, 4539, 4540, 4541, 4542, 4543, 4544, 4545, 4546, 4547, 4548, 4549, 4550, 4551, 4552, 4553,
    4554, 4555, 4556, 4557, 4558, 4559, 4560, 4561, 4562, 4563, 4564, 4565, 4566, 4567, 4568, 4569, 4570, 4571, 4572, 4573, 4574, 4575, 4576, 4577, 4578, 4579, 4580, 4581, 4582, 4583, 4584, 4585,
    4586, 4587, 4588, 4589, 4590, 4591, 4592, 4593, 4594, 4595, 4596, 4597, 4598, 4599, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617,
    4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, 4628, 4629, 4630, 4631, 4632, 4633, 4634, 4635, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4645, 4646, 4647, 4648, 4649,
    4650, 4651, 4652, 4653, 4654, 4655, 4656, 4657, 4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, 4680, 4681,
    4682, 4683, 4684, 4685, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713,
    4714, 4715, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4731, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, 4740, 4741, 4742, 4743, 4744, 4745,
    4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, 4759, 4760, 4761, 4762, 4763, 4764, 4765, 4766, 4767, 4768, 4769, 4770, 4771, 4772, 4773, 4774, 4775, 4776, 4777,
    4778, 4779, 4780, 4781, 4782, 4783, 4784, 4785, 4786, 4787, 4788, 4789, 4790, 4791, 4792, 4793, 4794, 4795, 4796, 4797, 4798, 4799, 4800, 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809,
    4810, 4811, 4812, 4813, 4814, 4815, 4816, 4817, 4818, 4819, 4820, 4821, 4822, 4823, 4824, 4825, 4826, 4827, 4828, 4829, 4830, 4831, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840, 4841,
    4842, 4843, 4844, 4845, 4846, 4847, 4848, 4849, 4850, 4851, 4852, 4853, 4854, 4855, 4856, 4857, 4858, 4859, 4860, 4861, 4862, 4863, 4864, 4865, 4866, 4867, 4868, 4869, 4870, 4871, 4872, 4873,
    4874, 4875, 4876, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, 4887, 4888, 4889, 4890, 4891, 4892, 4893, 4894, 4895, 4896, 4897, 4898, 4899, 4900, 4901, 4902, 4903, 4904, 4905,
    4906, 4907, 4908, 4909, 4910, 4911, 4912, 4913, 4914, 4915, 4916, 4917, 4918, 4919, 4920, 4921, 4922, 4923, 4924, 4925, 4926, 4927, 4928, 4929, 4930, 4931, 4932, 4933, 4934, 4935, 4936, 4937,
    4938, 4939, 4940, 4941, 4942, 4943, 4944, 4945, 4946, 4947, 4948, 4949, 4950, 4951, 4952, 4953, 4954, 4955, 4956, 4957, 4958, 4959, 4960, 4961, 4962, 4963, 4964, 4965, 4966, 4967, 4968, 4969,
    4970, 4971, 4972, 4973, 4974, 4975, 4976, 4977, 4978, 4979, 4980, 4981, 4982, 4983, 4984, 4985, 4986, 4987, 4988, 4989, 4990, 4991, 4992, 4993, 4994, 4995, 4996, 4997, 4998, 4999, 5000, 5001,
    5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 5032, 5033,
    5034, 5035, 5036, 5037, 5038, 5039, 5040, 5041, 5042, 5043, 5044, 5045, 5046, 5047, 5048, 5049, 5050, 5051, 5052, 5053, 5054, 5055, 5056, 5057, 5058, 5059, 5060, 5061, 5062, 5063, 5064, 5065,
    5066, 5067, 5068, 5069, 5070, 5071, 5072, 5073, 5074, 5075, 5076, 5077, 5078, 5079, 5080, 5081, 5082, 5083, 5084, 5085, 5086, 5087, 5088, 5089, 5090, 5091, 5092, 5093, 5094, 5095, 5096, 5097,
    5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106, 5107, 5108, 5109, 5110, 5111, 5112, 5113, 5114, 5115, 5116, 5117, 5118, 5119, 5120, 5121, 5122, 5123, 5124, 5125, 5126, 5127, 5128, 5129,
    5130, 5131, 5132, 5133, 5134, 5135, 5136, 5137, 5138, 5139, 5140, 5141, 5142, 5143, 5144, 5145, 5146, 5147, 5148, 5149, 5150, 5151, 5152, 5153, 5154, 5155, 5156, 5157, 5158, 5159, 5160, 5161,
    5162, 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5170, 5171, 5172, 5173, 5174, 5175, 5176, 5177, 5178, 5179, 5180, 5181, 5182, 5183, 5184, 5185, 5186, 5187, 5188, 5189, 5190, 5191, 5192, 5193,
    5194, 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, 5203, 5204, 5205, 5206, 5207, 5208, 5209, 5210, 5211, 5212, 5213, 5214, 5215, 5216, 5217, 5218, 5219, 5220, 5221, 5222, 5223, 5224, 5225,
    5226, 5227, 5228, 5229, 5230, 5231, 5232, 5233, 5234, 5235, 5236, 5237, 5238, 5239, 5240, 5241, 5242, 5243, 5244, 5245, 5246, 5247, 5248, 5249, 5250, 5251, 5252, 5253, 5254, 5255, 5256, 5257,
    5258, 5259, 5260, 5261, 5262, 5263, 5264, 5265, 5266, 5267, 5268, 5269, 5270, 5271, 5272, 5273, 5274, 5275, 5276, 5277, 5278, 5279, 5280, 5281, 5282, 5283, 5284, 5285, 5286, 5287, 5288, 5289,
    5290, 5291, 5292, 5293, 5294, 5295, 5296, 5297, 5298, 5299, 5300, 5301, 5302, 5303, 5304, 5305, 5306, 5307, 5308, 5309, 5310, 5311, 5312, 5313, 5314, 5315, 5316, 5317, 5318, 5319, 5320, 5321,
    5322, 5323, 5324, 5325, 5326, 5327, 5328, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 5336, 5337, 5338, 5339, 5340, 5341, 5342, 5343, 5344, 5345, 5346, 5347, 5348, 5349, 5350, 5351, 5352, 5353,
    5354, 5355, 5356, 5357, 5358, 5359, 5360, 5361, 5362, 5363, 5364, 5365, 5366, 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, 5383, 5384, 5385,
    5386, 5387, 5388, 5389, 5390, 5391, 5392, 5393, 5394, 5395, 5396, 5397, 5398, 5399, 5400, 5401, 5402, 5403, 5404, 5405, 5406, 5407, 5408, 5409, 5410, 5411, 5412, 5413, 5414, 5415, 5416, 5417,
    5418, 5419, 5420, 5421, 5422, 5423, 5424, 5425, 5426, 5427, 5428, 5429, 5430, 5431, 5432, 5433, 5434, 5435, 5436, 5437, 5438, 5439, 5440, 5441, 5442, 5443, 5444, 5445, 5446, 5447, 5448, 5449,
    5450, 5451, 5452, 5453, 5454, 5455, 5456, 5457, 5458, 5459, 5460, 5461, 5462, 5463, 5464, 5465, 5466, 5467, 5468, 5469, 5470, 5471, 5472, 5473, 5474, 5475, 5476, 5477, 5478, 5479, 5480, 5481,
    5482, 5483, 5484, 5485, 5486, 5487, 5488, 5489, 5490, 5491, 5492, 5493, 5494, 5495, 5496, 5497, 5498, 5499, 5500, 5501, 5502, 5503, 5504, 5505, 5506, 5507, 5508, 5509, 5510, 5511, 5512, 5513,
    5514, 5515, 5516, 5517, 5518, 5519, 5520, 5521, 5522, 5523, 5524, 5525, 5526, 5527, 5528, 5529, 5530, 5531, 5532, 5533, 5534, 5535, 5536, 5537, 5538, 5539, 5540, 5541, 5542, 5543, 5544, 5545,
    5546, 5547, 5548, 5549, 5550, 5551, 5552, 5553, 5554, 5555, 5556, 5557, 5558, 5559, 5560, 5561, 5562, 5563, 5564, 5565, 5566, 5567, 5568, 5569, 5570, 5571, 5572, 5573, 5574, 5575, 5576, 5577,
    5578, 5579, 5580, 5581, 5582, 5583, 5584, 5585, 5586, 5587, 5588, 5589, 5590, 5591, 5592, 5593, 5594, 5595, 5596, 5597, 5598, 5599, 5600, 5601, 5602, 5603, 5604, 5605, 5606, 5607, 5608, 5609,
    5610, 5611, 5612, 5613, 5614, 5615, 5616, 5617, 5618, 5619, 5620, 5621, 5622, 5623, 5624, 5625, 5626, 5627, 5628, 5629, 5630, 5631, 5632, 5633, 5634, 5635, 5636, 5637, 5638, 5639, 5640, 5641,
    5642, 5643, 5644, 5645, 5646, 5647, 5648, 5649, 5650, 5651, 5652, 5653, 5654, 5655, 5656, 5657, 5658, 5659, 5660, 5661, 5662, 5663, 5664, 5665, 5666, 5667, 5668, 5669, 5670, 5671, 5672, 5673,
    5674, 5675, 5676, 5677, 5678, 5679, 5680, 5681, 5682, 5683, 5684, 5685, 5686, 5687, 5688, 5689, 5690, 5691, 5692, 5693, 5694, 5695, 5696, 5697, 5698, 5699, 5700, 5701, 5702, 5703, 5704, 5705,
    5706, 5707, 5708, 5709, 5710, 5711, 5712, 5713, 5714, 5715, 5716, 5717, 5718, 5719, 5720, 5721, 5722, 5723, 5724, 5725, 5726, 5727, 5728, 5729, 5730, 5731, 5732, 5733, 5734, 5735, 5736, 5737,
    5738, 5739, 5740, 5741, 5742, 5743, 5744, 5745, 5746, 5747, 5748, 5749, 5750, 5751, 5752, 5753, 5754, 5755, 5756, 5757, 5758, 5759, 5760, 5761, 5762, 5763, 5764, 5765, 5766, 5767, 5768, 5769,
    5770, 5771, 5772, 5773, 5774, 5775, 5776, 5777, 5778, 5779, 5780, 5781, 5782, 5783, 5784, 5785, 5786, 5787, 5788, 5789, 5790, 5791, 5792, 5793, 5794, 5795, 5796, 5797, 5798, 5799, 5800, 5801,
    5802, 5803, 5804, 5805, 5806, 5807, 5808, 5809, 5810, 5811, 5812, 5813, 5814, 5815, 5816, 5817, 5818, 5819, 5820, 5821, 5822, 5823, 5824, 5825, 5826, 5827, 5828, 5829, 5830, 5831, 5832, 5833,
    5834, 5835, 5836, 5837, 5838, 5839, 5840, 5841, 5842, 5843, 5844, 5845, 5846, 5847, 5848, 5849, 5850, 5851, 5852, 5853, 5854, 5855, 5856, 5857, 5858, 5859, 5860, 5861, 5862, 5863, 5864, 5865,
    5866, 5867, 5868, 5869, 5870, 5871, 5872, 5873, 5874, 5875, 5876, 5877, 5878, 5879, 5880, 5881, 5882, 5883, 5884, 5885, 5886, 5887, 5888, 5889, 5890, 5891, 5892, 5893, 5894, 5895, 5896, 5897,
    5898, 5899, 5900, 5901, 5902, 5903, 5904, 5905, 5906, 5907, 5908, 5909, 5910, 5911, 5912, 5913, 5914, 5915, 5916, 5917, 5918, 5919, 5920, 5921, 5922, 5923, 5924, 5925, 5926, 5927, 5928, 5929,
    5930, 5931, 5932, 5933, 5934, 5935, 5936, 5937, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5945, 5946, 5947, 5948, 5949, 5950, 5951, 5952, 5953, 5954, 5955, 5956, 5957, 5958, 5959, 5960, 5961,
    5962, 5963, 5964, 5965, 5966, 5967, 5968, 5969, 5970, 5971, 5972, 5973, 5974, 5975, 5976, 5977, 5978, 5979, 5980, 5981, 5982, 5983, 5984, 5985, 5986, 5987, 5988, 5989, 5990, 5991, 5992, 5993,
    5994, 5995, 5996, 5997, 5998, 5999, 6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6009, 6010, 6011, 6012, 6013, 6014, 6015, 6016, 6017, 6018, 6019, 6020, 6021, 6022, 6023, 6024, 6025,
    6026, 6027, 6028, 6029, 6030, 6031, 6032, 6033, 6034, 6035, 6036, 6037, 6038, 6039, 6040, 6041, 6042, 6043, 6044, 6045, 6046, 6047, 6048, 6049, 6050, 6051, 6052, 6053, 6054, 6055, 6056, 6057,
    6058, 6059, 6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069, 6070, 6071, 6072, 6073, 6074, 6075, 6076, 6077, 6078, 6079, 6080, 6081, 6082, 6083, 6084, 6085, 6086, 6087, 6088, 6089,
    6090, 6091, 6092, 6093, 6094, 6095, 6096, 6097, 6098, 6099, 6100, 6101, 6102, 6103, 6104, 6105, 6106, 6107, 6108, 6109, 6110, 6111, 6112, 6113, 6114, 6115, 6116, 6117, 6118, 6119, 6120, 6121,
    6122, 6123, 6124, 6125, 6126, 6127, 6128, 6129, 6130, 6131, 6132, 6133, 6134, 6135, 6136, 6137, 6138, 6139, 6140, 6141, 6142, 6143, 6143, 6142, 6141, 6140, 6139, 6138, 6137, 6136, 6135, 6134,
    6133, 6132, 6131, 6130, 6129, 6128, 6127, 6126, 6125, 6124, 6123, 6122, 6121, 6120, 6119, 6118, 6117, 6116, 6115, 6114, 6113, 6112, 6111, 6110, 6109, 6108, 6107, 6106, 6105, 6104, 6103, 6102,
    6101, 6100, 6099, 6098, 6097, 6096, 6095, 6094, 6093, 6092, 6091, 6090, 6089, 6088, 6087, 6086, 6085, 6084, 6083, 6082, 6081, 6080, 6079, 6078, 6077, 6076, 6075, 6074, 6073, 6072, 6071, 6070,
    6069, 6068, 6067, 6066, 6065, 6064, 6063, 6062, 6061, 6060, 6059, 6058, 6057, 6056, 6055, 6054, 6053, 6052, 6051, 6050, 6049, 6048, 6047, 6046, 6045, 6044, 6043, 6042, 6041, 6040, 6039, 6038,
    6037, 6036, 6035, 6034, 6033, 6032, 6031, 6030, 6029, 6028, 6027, 6026, 6025, 6024, 6023, 6022, 6021, 6020, 6019, 6018, 6017, 6016, 6015, 6014, 6013, 6012, 6011, 6010, 6009, 6008, 6007, 6006,
    6005, 6004, 6003, 6002, 6001, 6000, 5999, 5998, 5997, 5996, 5995, 5994, 5993, 5992, 5991, 5990, 5989, 5988, 5987, 5986, 5985, 5984, 5983, 5982, 5981, 5980, 5979, 5978, 5977, 5976, 5975, 5974,
    5973, 5972, 5971, 5970, 5969, 5968, 5967, 5966, 5965, 5964, 5963, 5962, 5961, 5960, 5959, 5958, 5957, 5956, 5955, 5954, 5953, 5952, 5951, 5950, 5949, 5948, 5947, 5946, 5945, 5944, 5943, 5942,
    5941, 5940, 5939, 5938, 5937, 5936, 5935, 5934, 5933, 5932, 5931, 5930, 5929, 5928, 5927, 5926, 5925, 5924, 5923, 5922, 5921, 5920, 5919, 5918, 5917, 5916, 5915, 5914, 5913, 5912, 5911, 5910,
    5909, 5908, 5907, 5906, 5905, 5904, 5903, 5902, 5901, 5900, 5899, 5898, 5897, 5896, 5895, 5894, 5893, 5892, 5891, 5890, 5889, 5888, 5887, 5886, 5885, 5884, 5883, 5882, 5881, 5880, 5879, 5878,
    5877, 5876, 5875, 5874, 5873, 5872, 5871, 5870, 5869, 5868, 5867, 5866, 5865, 5864, 5863, 5862, 5861, 5860, 5859, 5858, 5857, 5856, 5855, 5854, 5853, 5852, 5851, 5850, 5849, 5848, 5847, 5846,
    5845, 5844, 5843, 5842, 5841, 5840, 5839, 5838, 5837, 5836, 5835, 5834, 5833, 5832, 5831, 5830, 5829, 5828, 5827, 5826, 5825, 5824, 5823, 5822, 5821, 5820, 5819, 5818, 5817, 5816, 5815, 5814,
    5813, 5812, 5811, 5810, 5809, 5808, 5807, 5806, 5805, 5804, 5803, 5802, 5801, 5800, 5799, 5798, 5797, 5796, 5795, 5794, 5793, 5792, 5791, 5790, 5789, 5788, 5787, 5786, 5785, 5784, 5783, 5782,
    5781, 5780, 5779, 5778, 5777, 5776, 5775, 5774, 5773, 5772, 5771, 5770, 5769, 5768, 5767, 5766, 5765, 5764, 5763, 5762, 5761, 5760, 5759, 5758, 5757, 5756, 5755, 5754, 5753, 5752, 5751, 5750,
    6334, 6335, 6336, 6337, 6338, 6339, 6340, 6341, 6342, 6343, 6344, 6345, 6346, 6347, 6348, 6349, 6350, 6351, 6352, 6353, 6354, 6355, 6356, 6357, 6358, 6359, 6360, 6361, 6362, 6363, 6364, 6365,
    6366, 6367, 6368, 6369, 6370, 6371, 6372, 6373, 6374, 6375, 6376, 6377, 6378, 6379, 6380, 6381, 6382, 6383, 6384, 6385, 6386, 6387, 6388, 6389, 6390, 6391, 6392, 6393, 6394, 6395, 6396, 6397,
    6398, 6399, 6400, 6401, 6402, 6403, 6404, 6405, 6406, 6407, 6408, 6409, 6410, 6411, 6412, 6413, 6414, 6415, 6416, 6417, 6418, 6419, 6420, 6421, 6422, 6423, 6424, 6425, 6426, 6427, 6428, 6429,
    6430, 6431, 6432, 6433, 6434, 6435, 6436, 6437, 6438, 6439, 6440, 6441, 6442, 6443, 6444, 6445, 6446, 6447, 6448, 6449, 6450, 6451, 6452, 6453, 6454, 6455, 6456, 6457, 6458, 6459, 6460, 6461,
    6462, 6463, 6464, 6465, 6466, 6467, 6468, 6469, 6470, 6471, 6472, 6473, 6474, 6475, 6476, 6477, 6478, 6479, 6480, 6481, 6482, 6483, 6484, 6485, 6486, 6487, 6488, 6489, 6490, 6491, 6492, 6493,
    6494, 6495, 6496, 6497, 6498, 6499, 6500, 6501, 6502, 6503, 6504, 6505, 6506, 6507, 6508, 6509, 6510, 6511, 6512, 6513, 6514, 6515, 6516, 6517, 6518, 6519, 6520, 6521, 6522, 6523, 6524, 6525,
    6526, 6527, 6528, 6529, 6530, 6531, 6532, 6533, 6534, 6535, 6536, 6537, 6538, 6539, 6540, 6541, 6542, 6543, 6544, 6545, 6546, 6547, 6548, 6549, 6550, 6551, 6552, 6553, 6554, 6555, 6556, 6557,
    6558, 6559, 6560, 6561, 6562, 6563, 6564, 6565, 6566, 6567, 6568, 6569, 6570, 6571, 6572, 6573, 6574, 6575, 6576, 6577, 6578, 6579, 6580, 6581, 6582, 6583, 6584, 6585, 6586, 6587, 6588, 6589,
    6590, 6591, 6592, 6593, 6594, 6595, 6596, 6597, 6598, 6599, 6600, 6601, 6602, 6603, 6604, 6605, 6606, 6607, 6608, 6609, 6610, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621,
    6622, 6623, 6624, 6625, 6626, 6627, 6628, 6629, 6630, 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6642, 6643, 6644, 6645, 6646, 6647, 6648, 6649, 6650, 6651, 6652, 6653,
    6654, 6655, 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678, 6679, 6680, 6681, 6682, 6683, 6684, 6685,
    6686, 6687, 6688, 6689, 6690, 6691, 6692, 6693, 6694, 6695, 6696, 6697, 6698, 6699, 6700, 6701, 6702, 6703, 6704, 6705, 6706, 6707, 6708, 6709, 6710, 6711, 6712, 6713, 6714, 6715, 6716, 6717,
    6718, 6719, 6720, 6721, 6722, 6723, 6724, 6725, 6726, 6727, 6728, 6729, 6730, 6731, 6732, 6733, 6734, 6735, 6736, 6737, 6738, 6739, 6740, 6741, 6742, 6743, 6744, 6745, 6746, 6747, 6748, 6749,
    6750, 6751, 6752, 6753, 6754, 6755, 6756, 6757, 6758, 6759, 6760, 6761, 6762, 6763, 6764, 6765, 6766, 6767, 6768, 6769, 6770, 6771, 6772, 6773, 6774, 6775, 6776, 6777, 6778, 6779, 6780, 6781,
    6782, 6783, 6784, 6785, 6786, 6787, 6788, 6789, 6790, 6791, 6792, 6793, 6794, 6795, 6796, 6797, 6798, 6799, 6800, 6801, 6802, 6803, 6804, 6805, 6806, 6807, 6808, 6809, 6810, 6811, 6812, 6813,
    6814, 6815, 6816, 6817, 6818, 6819, 6820, 6821, 6822, 6823, 6824, 6825, 6826, 6827, 6828, 6829, 6830, 6831, 6832, 6833, 6834, 6835, 6836, 6837, 6838, 6839, 6840, 6841, 6842, 6843, 6844, 6845,
    6846, 6847, 6848, 6849, 6850, 6851, 6852, 6853, 6854, 6855, 6856, 6857, 6858, 6859, 6860, 6861, 6862, 6863, 6864, 6865, 6866, 6867, 6868, 6869, 6870, 6871, 6872, 6873, 6874, 6875, 6876, 6877,
    6878, 6879, 6880, 6881, 6882, 6883, 6884, 6885, 6886, 6887, 6888, 6889, 6890, 6891, 6892, 6893, 6894, 6895, 6896, 6897, 6898, 6899, 6900, 6901, 6902, 6903, 6904, 6905, 6906, 6907, 6908, 6909,
    6910, 6911, 6912, 6913, 6914, 6915, 6916, 6917, 6918, 6919, 6920, 6921, 6922, 6923, 6924, 6925, 6926, 6927, 6928, 6929, 6930, 6931, 6932, 6933, 6934, 6935, 6936, 6937, 6938, 6939, 6940, 6941,
    6942, 6943, 6944, 6945, 6946, 6947, 6948, 6949, 6950, 6951, 6952, 6953, 6954, 6955, 6956, 6957, 6958, 6959, 6960, 6961, 6962, 6963, 6964, 6965, 6966, 6967, 6968, 6969, 6970, 6971, 6972, 6973,
    6974, 6975, 6976, 6977, 6978, 6979, 6980, 6981, 6982, 6983, 6984, 6985, 6986, 6987, 6988, 6989, 6990, 6991, 6992, 6993, 6994, 6995, 6996, 6997, 6998, 6999, 7000, 7001, 7002, 7003, 7004, 7005,
    7006, 7007, 7008, 7009, 7010, 7011, 7012, 7013, 7014, 7015, 7016, 7017, 7018, 7019, 7020, 7021, 7022, 7023, 7024, 7025, 7026, 7027, 7028, 7029, 7030, 7031, 7032, 7033, 7034, 7035, 7036, 7037,
    7038, 7039, 7040, 7041, 7042, 7043, 7044, 7045, 7046, 7047, 7048, 7049, 7050, 7051, 7052, 7053, 7054, 7055, 7056, 7057, 7058, 7059, 7060, 7061, 7062, 7063, 7064, 7065, 7066, 7067, 7068, 7069,
    7070, 7071, 7072, 7073, 7074, 7075, 7076, 7077, 7078, 7079, 7080, 7081, 7082, 7083, 7084, 7085, 7086, 7087, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, 7096, 7097, 7098, 7099, 7100, 7101,
    7102, 7103, 7104, 7105, 7106, 7107, 7108, 7109, 7110, 7111, 7112, 7113, 7114, 7115, 7116, 7117, 7118, 7119, 7120, 7121, 7122, 7123, 7124, 7125, 7126, 7127, 7128, 7129, 7130, 7131, 7132, 7133,
    7134, 7135, 7136, 7137, 7138, 7139, 7140, 7141, 7142, 7143, 7144, 7145, 7146, 7147, 7148, 7149, 7150, 7151, 7152, 7153, 7154, 7155, 7156, 7157, 7158, 7159, 7160, 7161, 7162, 7163, 7164, 7165,
    7166, 7167, 7168, 7169, 7170, 7171, 7172, 7173, 7174, 7175, 7176, 7177, 7178, 7179, 7180, 7181, 7182, 7183, 7184, 7185, 7186, 7187, 7188, 7189, 7190, 7191, 7192, 7193, 7194, 7195, 7196, 7197,
    7198, 7199, 7200, 7201, 7202, 7203, 7204, 7205, 7206, 7207, 7208, 7209, 7210, 7211, 7212, 7213, 7214, 7215, 7216, 7217, 7218, 7219, 7220, 7221, 7222, 7223, 7224, 7225, 7226, 7227, 7228, 7229,
    7230, 7231, 7232, 7233, 7234, 7235, 7236, 7237, 7238, 7239, 7240, 7241, 7242, 7243, 7244, 7245, 7246, 7247, 7248, 7249, 7250, 7251, 7252, 7253, 7254, 7255, 7256, 7257, 7258, 7259, 7260, 7261,
    7262, 7263, 7264, 7265, 7266, 7267, 7268, 7269, 7270, 7271, 7272, 7273, 7274, 7275, 7276, 7277, 7278, 7279, 7280, 7281, 7282, 7283, 7284, 7285, 7286, 7287, 7288, 7289, 7290, 7291, 7292, 7293,
    7294, 7295, 7296, 7297, 7298, 7299, 7300, 7301, 7302, 7303, 7304, 7305, 7306, 7307, 7308, 7309, 7310, 7311, 7312, 7313, 7314, 7315, 7316, 7317, 7318, 7319, 7320, 7321, 7322, 7323, 7324, 7325,
    7326, 7327, 7328, 7329, 7330, 7331, 7332, 7333, 7334, 7335, 7336, 7337, 7338, 7339, 7340, 7341, 7342, 7343, 7344, 7345, 7346, 7347, 7348, 7349, 7350, 7351, 7352, 7353, 7354, 7355, 7356, 7357,
    7358, 7359, 7360, 7361, 7362, 7363, 7364, 7365, 7366, 7367, 7368, 7369, 7370, 7371, 7372, 7373, 7374, 7375, 7376, 7377, 7378, 7379, 7380, 7381, 7382, 7383, 7384, 7385, 7386, 7387, 7388, 7389,
    7390, 7391, 7392, 7393, 7394, 7395, 7396, 7397, 7398, 7399, 7400, 7401, 7402, 7403, 7404, 7405, 7406, 7407, 7408, 7409, 7410, 7411, 7412, 7413, 7414, 7415, 7416, 7417, 7418, 7419, 7420, 7421,
    7422, 7423, 7424, 7425, 7426, 7427, 7428, 7429, 7430, 7431, 7432, 7433, 7434, 7435, 7436, 7437, 7438, 7439, 7440, 7441, 7442, 7443, 7444, 7445, 7446, 7447, 7448, 7449, 7450, 7451, 7452, 7453,
    7454, 7455, 7456, 7457, 7458, 7459, 7460, 7461, 7462, 7463, 7464, 7465, 7466, 7467, 7468, 7469, 7470, 7471, 7472, 7473, 7474, 7475, 7476, 7477, 7478, 7479, 7480, 7481, 7482, 7483, 7484, 7485,
    7486, 7487, 7488, 7489, 7490, 7491, 7492, 7493, 7494, 7495, 7496, 7497, 7498, 7499, 7500, 7501, 7502, 7503, 7504, 7505, 7506, 7507, 7508, 7509, 7510, 7511, 7512, 7513, 7514, 7515, 7516, 7517,
    7518, 7519, 7520, 7521, 7522, 7523, 7524, 7525, 7526, 7527, 7528, 7529, 7530, 7531, 7532, 7533, 7534, 7535, 7536, 7537, 7538, 7539, 7540, 7541, 7542, 7543, 7544, 7545, 7546, 7547, 7548, 7549,
    7550, 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558, 7559, 7560, 7561, 7562, 7563, 7564, 7565, 7566, 7567, 7568, 7569, 7570, 7571, 7572, 7573, 7574, 7575, 7576, 7577, 7578, 7579, 7580, 7581,
    7582, 7583, 7584, 7585, 7586, 7587, 7588, 7589, 7590, 7591, 7592, 7593, 7594, 7595, 7596, 7597, 7598, 7599, 7600, 7601, 7602, 7603, 7604, 7605, 7606, 7607, 7608, 7609, 7610, 7611, 7612, 7613,
    7614, 7615, 7616, 7617, 7618, 7619, 7620, 7621, 7622, 7623, 7624, 7625, 7626, 7627, 7628, 7629, 7630, 7631, 7632, 7633, 7634, 7635, 7636, 7637, 7638, 7639, 7640, 7641, 7642, 7643, 7644, 7645,
    7646, 7647, 7648, 7649, 7650, 7651, 7652, 7653, 7654, 7655, 7656, 7657, 7658, 7659, 7660, 7661, 7662, 7663, 7664, 7665, 7666, 7667, 7668, 7669, 7670, 7671, 7672, 7673, 7674, 7675, 7676, 7677,
    7678, 7679, 7680, 7681, 7682, 7683, 7684, 7685, 7686, 7687, 7688, 7689, 7690, 7691, 7692, 7693, 7694, 7695, 7696, 7697, 7698, 7699, 7700, 7701, 7702, 7703, 7704, 7705, 7706, 7707, 7708, 7709,
    7710, 7711, 7712, 7713, 7714, 7715, 7716, 7717, 7718, 7719, 7720, 7721, 7722, 7723, 7724, 7725, 7726, 7727, 7728, 7729, 7730, 7731, 7732, 7733, 7734, 7735, 7736, 7737, 7738, 7739, 7740, 7741,
    7742, 7743, 7744, 7745, 7746, 7747, 7748, 7749, 7750, 7751, 7752, 7753, 7754, 7755, 7756, 7757, 7758, 7759, 7760, 7761, 7762, 7763, 7764, 7765, 7766, 7767, 7768, 7769, 7770, 7771, 7772, 7773,
    7774, 7775, 7776, 7777, 7778, 7779, 7780, 7781, 7782, 7783, 7784, 7785, 7786, 7787, 7788, 7789, 7790, 7791, 7792, 7793, 7794, 7795, 7796, 7797, 7798, 7799, 7800, 7801, 7802, 7803, 7804, 7805,
    7806, 7807, 7808, 7809, 7810, 7811, 7812, 7813, 7814, 7815, 7816, 7817, 7818, 7819, 7820, 7821, 7822, 7823, 7824, 7825, 7826, 7827, 7828, 7829, 7830, 7831, 7832, 7833, 7834, 7835, 7836, 7837,
    7838, 7839, 7840, 7841, 7842, 7843, 7844, 7845, 7846, 7847, 7848, 7849, 7850, 7851, 7852, 7853, 7854, 7855, 7856, 7857, 7858, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7866, 7867, 7868, 7869,
    7870, 7871, 7872, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, 7884, 7885, 7886, 7887, 7888, 7889, 7890, 7891, 7892, 7893, 7894, 7895, 7896, 7897, 7898, 7899, 7900, 7901,
    7902, 7903, 7904, 7905, 7906, 7907, 7908, 7909, 7910, 7911, 7912, 7913, 7914, 7915, 7916, 7917, 7918, 7919, 7920, 7921, 7922, 7923, 7924, 7925, 7926, 7927, 7928, 7929, 7930, 7931, 7932, 7933,
    7934, 7935, 7936, 7937, 7938, 7939, 7940, 7941, 7942, 7943, 7944, 7945, 7946, 7947, 7948, 7949, 7950, 7951, 7952, 7953, 7954, 7955, 7956, 7957, 7958, 7959, 7960, 7961, 7962, 7963, 7964, 7965,
    7966, 7967, 7968, 7969, 7970, 7971, 7972, 7973, 7974, 7975, 7976, 7977, 7978, 7979, 7980, 7981, 7982, 7983, 7984, 7985, 7986, 7987, 7988, 7989, 7990, 7991, 7992, 7993, 7994, 7995, 7996, 7997,
    7998, 7999, 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009, 8010, 8011, 8012, 8013, 8014, 8015, 8016, 8017, 8018, 8019, 8020, 8021, 8022, 8023, 8024, 8025, 8026, 8027, 8028, 8029,
    8030, 8031, 8032, 8033, 8034, 8035, 8036, 8037, 8038, 8039, 8040, 8041, 8042, 8043, 8044, 8045, 8046, 8047, 8048, 8049, 8050, 8051, 8052, 8053, 8054, 8055, 8056, 8057, 8058, 8059, 8060, 8061,
    8062, 8063, 8064, 8065, 8066, 8067, 8068, 8069, 8070, 8071, 8072, 8073, 8074, 8075, 8076, 8077, 8078, 8079, 8080, 8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, 8090, 8091, 8092, 8093,
    8094, 8095, 8096, 8097, 8098, 8099, 8100, 8101, 8102, 8103, 8104, 8105, 8106, 8107, 8108, 8109, 8110, 8111, 8112, 8113, 8114, 8115, 8116, 8117, 8118, 8119, 8120, 8121, 8122, 8123, 8124, 8125,
    8126, 8127, 8128, 8129, 8130, 8131, 8132, 8133, 8134, 8135, 8136, 8137, 8138, 8139, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157,
    8158, 8159, 8160, 8161, 8162, 8163, 8164, 8165, 8166, 8167, 8168, 8169, 8170, 8171, 8172, 8173, 8174, 8175, 8176, 8177, 8178, 8179, 8180, 8181, 8182, 8183, 8184, 8185, 8186, 8187, 8188, 8189,
    8190, 8191, 8191, 8190, 8189, 8188, 8187, 8186, 8185, 8184, 8183, 8182, 8181, 8180, 8179, 8178, 8177, 8176, 8175, 8174, 8173, 8172, 8171, 8170, 8169, 8168, 8167, 8166, 8165, 8164, 8163, 8162,
    8161, 8160, 8159, 8158, 8157, 8156, 8155, 8154, 8153, 8152, 8151, 8150, 8149, 8148, 8147, 8146, 8145, 8144, 8143, 8142, 8141, 8140, 8139, 8138, 8137, 8136, 8135, 8134, 8133, 8132, 8131, 8130,
    8129, 8128, 8127, 8126, 8125, 8124, 8123, 8122, 8121, 8120, 8119, 8118, 8117, 8116, 8115, 8114, 8113, 8112, 8111, 8110, 8109, 8108, 8107, 8106, 8105, 8104, 8103, 8102, 8101, 8100, 8099, 8098,
    8097, 8096, 8095, 8094, 8093, 8092, 8091, 8090, 8089, 8088, 8087, 8086, 8085, 8084, 8083, 8082, 8081, 8080, 8079, 8078, 8077, 8076, 8075, 8074, 8073, 8072, 8071, 8070, 8069, 8068, 8067, 8066,
    8065, 8064, 8063, 8062, 8061, 8060, 8059, 8058, 8057, 8056, 8055, 8054, 8053, 8052, 8051, 8050, 8049, 8048, 8047, 8046, 8045, 8044, 8043, 8042, 8041, 8040, 8039, 8038, 8037, 8036, 8035, 8034,
    8033, 8032, 8031, 8030, 8029, 8028, 8027, 8026, 8025, 8024, 8023, 8022, 8021, 8020, 8019, 8018, 8017, 8016, 8015, 8014, 8013, 8012, 8011, 8010, 8009, 8008, 8007, 8006, 8005, 8004, 8003, 8002,
    6236, 6237, 6238, 6239, 6240, 6241, 6242, 6243, 6244, 6245, 6246, 6247, 6248, 6249, 6250, 6251, 6252, 6253, 6254, 6255, 6256, 6257, 6258, 6259, 6260, 6261, 6262, 6263, 6264, 6265, 6266, 6267,
    6268, 6269, 6270, 6271, 6272, 6273, 6274, 6275, 6276, 6277, 6278, 6279, 6280, 6281, 6282, 6283, 6284, 6285, 6286, 6287, 6288, 6289, 6290, 6291, 6292, 6293, 6294, 6295, 6296, 6297, 6298, 6299,
    6300, 6301, 6302, 6303, 6304, 6305, 6306, 6307, 6308, 6309, 6310, 6311, 6312, 6313, 6314, 6315, 6316, 6317, 6318, 6319, 6320, 6321, 6322, 6323, 6324, 6325, 6326, 6327, 6328, 6329, 6330, 6331,
    6332, 6333, 6334, 6335, 6336, 6337, 6338, 6339, 6340, 6341, 6342, 6343, 6344, 6345, 6346, 6347, 6348, 6349, 6350, 6351, 6352, 6353, 6354, 6355, 6356, 6357, 6358, 6359, 6360, 6361, 6362, 6363,
    6364, 6365, 6366, 6367, 6368, 6369, 6370, 6371, 6372, 6373, 6374, 6375, 6376, 6377, 6378, 6379, 6380, 6381, 6382, 6383, 6384, 6385, 6386, 6387, 6388, 6389, 6390, 6391, 6392, 6393, 6394, 6395,
    6396, 6397, 6398, 6399, 6400, 6401, 6402, 6403, 6404, 6405, 6406, 6407, 6408, 6409, 6410, 6411, 6412, 6413, 6414, 6415, 6416, 6417, 6418, 6419, 6420, 6421, 6422, 6423, 6424, 6425, 6426, 6427,
    6428, 6429, 6430, 6431, 6432, 6433, 6434, 6435, 6436, 6437, 6438, 6439, 6440, 6441, 6442, 6443, 6444, 6445, 6446, 6447, 6448, 6449, 6450, 6451, 6452, 6453, 6454, 6455, 6456, 6457, 6458, 6459,
    6460, 6461, 6462, 6463, 6464, 6465, 6466, 6467, 6468, 6469, 6470, 6471, 6472, 6473, 6474, 6475, 6476, 6477, 6478, 6479, 6480, 6481, 6482, 6483, 6484, 6485, 6486, 6487, 6488, 6489, 6490, 6491,
    6492, 6493, 6494, 6495, 6496, 6497, 6498, 6499, 6500, 6501, 6502, 6503, 6504, 6505, 6506, 6507, 6508, 6509, 6510, 6511, 6512, 6513, 6514, 6515, 6516, 6517, 6518, 6519, 6520, 6521, 6522, 6523,
    6524, 6525, 6526, 6527, 6528, 6529, 6530, 6531, 6532, 6533, 6534, 6535, 6536, 6537, 6538, 6539, 6540, 6541, 6542, 6543, 6544, 6545, 6546, 6547, 6548, 6549, 6550, 6551, 6552, 6553, 6554, 6555,
    6556, 6557, 6558, 6559, 6560, 6561, 6562, 6563, 6564, 6565, 6566, 6567, 6568, 6569, 6570, 6571, 6572, 6573, 6574, 6575, 6576, 6577, 6578, 6579, 6580, 6581, 6582, 6583, 6584, 6585, 6586, 6587,
    6588, 6589, 6590, 6591, 6592, 6593, 6594, 6595, 6596, 6597, 6598, 6599, 6600, 6601, 6602, 6603, 6604, 6605, 6606, 6607, 6608, 6609, 6610, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619,
    6620, 6621, 6622, 6623, 6624, 6625, 6626, 6627, 6628, 6629, 6630, 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6642, 6643, 6644, 6645, 6646, 6647, 6648, 6649, 6650, 6651,
    6652, 6653, 6654, 6655, 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678, 6679, 6680, 6681, 6682, 6683,
    6684, 6685, 6686, 6687, 6688, 6689, 6690, 6691, 6692, 6693, 6694, 6695, 6696, 6697, 6698, 6699, 6700, 6701, 6702, 6703, 6704, 6705, 6706, 6707, 6708, 6709, 6710, 6711, 6712, 6713, 6714, 6715,
    6716, 6717, 6718, 6719, 6720, 6721, 6722, 6723, 6724, 6725, 6726, 6727, 6728, 6729, 6730, 6731, 6732, 6733, 6734, 6735, 6736, 6737, 6738, 6739, 6740, 6741, 6742, 6743, 6744, 6745, 6746, 6747,
    6748, 6749, 6750, 6751, 6752, 6753, 6754, 6755, 6756, 6757, 6758, 6759, 6760, 6761, 6762, 6763, 6764, 6765, 6766, 6767, 6768, 6769, 6770, 6771, 6772, 6773, 6774, 6775, 6776, 6777, 6778, 6779,
    6780, 6781, 6782, 6783, 6784, 6785, 6786, 6787, 6788, 6789, 6790, 6791, 6792, 6793, 6794, 6795, 6796, 6797, 6798, 6799, 6800, 6801, 6802, 6803, 6804, 6805, 6806, 6807, 6808, 6809, 6810, 6811,
    6812, 6813, 6814, 6815, 6816, 6817, 6818, 6819, 6820, 6821, 6822, 6823, 6824, 6825, 6826, 6827, 6828, 6829, 6830, 6831, 6832, 6833, 6834, 6835, 6836, 6837, 6838, 6839, 6840, 6841, 6842, 6843,
    6844, 6845, 6846, 6847, 6848, 6849, 6850, 6851, 6852, 6853, 6854, 6855, 6856, 6857, 6858, 6859, 6860, 6861, 6862, 6863, 6864, 6865, 6866, 6867, 6868, 6869, 6870, 6871, 6872, 6873, 6874, 6875,
    6876, 6877, 6878, 6879, 6880, 6881, 6882, 6883, 6884, 6885, 6886, 6887, 6888, 6889, 6890, 6891, 6892, 6893, 6894, 6895, 6896, 6897, 6898, 6899, 6900, 6901, 6902, 6903, 6904, 6905, 6906, 6907,
    6908, 6909, 6910, 6911, 6912, 6913, 6914, 6915, 6916, 6917, 6918, 6919, 6920, 6921, 6922, 6923, 6924, 6925, 6926, 6927, 6928, 6929, 6930, 6931, 6932, 6933, 6934, 6935, 6936, 6937, 6938, 6939,
    6940, 6941, 6942, 6943, 6944, 6945, 6946, 6947, 6948, 6949, 6950, 6951, 6952, 6953, 6954, 6955, 6956, 6957, 6958, 6959, 6960, 6961, 6962, 6963, 6964, 6965, 6966, 6967, 6968, 6969, 6970, 6971,
    6972, 6973, 6974, 6975, 6976, 6977, 6978, 6979, 6980, 6981, 6982, 6983, 6984, 6985, 6986, 6987, 6988, 6989, 6990, 6991, 6992, 6993, 6994, 6995, 6996, 6997, 6998, 6999, 7000, 7001, 7002, 7003,
    7004, 7005, 7006, 7007, 7008, 7009, 7010, 7011, 7012, 7013, 7014, 7015, 7016, 7017, 7018, 7019, 7020, 7021, 7022, 7023, 7024, 7025, 7026, 7027, 7028, 7029, 7030, 7031, 7032, 7033, 7034, 7035,
    7036, 7037, 7038, 7039, 7040, 7041, 7042, 7043, 7044, 7045, 7046, 7047, 7048, 7049, 7050, 7051, 7052, 7053, 7054, 7055, 7056, 7057, 7058, 7059, 7060, 7061, 7062, 7063, 7064, 7065, 7066, 7067,
    7068, 7069, 7070, 7071, 7072, 7073, 7074, 7075, 7076, 7077, 7078, 7079, 7080, 7081, 7082, 7083, 7084, 7085, 7086, 7087, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, 7096, 7097, 7098, 7099,
    7100, 7101, 7102, 7103, 7104, 7105, 7106, 7107, 7108, 7109, 7110, 7111, 7112, 7113, 7114, 7115, 7116, 7117, 7118, 7119, 7120, 7121, 7122, 7123, 7124, 7125, 7126, 7127, 7128, 7129, 7130, 7131,
    7132, 7133, 7134, 7135, 7136, 7137, 7138, 7139, 7140, 7141, 7142, 7143, 7144, 7145, 7146, 7147, 7148, 7149, 7150, 7151, 7152, 7153, 7154, 7155, 7156, 7157, 7158, 7159, 7160, 7161, 7162, 7163,
    7164, 7165, 7166, 7167, 7168, 7169, 7170, 7171, 7172, 7173, 7174, 7175, 7176, 7177, 7178, 7179, 7180, 7181, 7182, 7183, 7184, 7185, 7186, 7187, 7188, 7189, 7190, 7191, 7192, 7193, 7194, 7195,
    7196, 7197, 7198, 7199, 7200, 7201, 7202, 7203, 7204, 7205, 7206, 7207, 7208, 7209, 7210, 7211, 7212, 7213, 7214, 7215, 7216, 7217, 7218, 7219, 7220, 7221, 7222, 7223, 7224, 7225, 7226, 7227,
    7228, 7229, 7230, 7231, 7232, 7233, 7234, 7235, 7236, 7237, 7238, 7239, 7240, 7241, 7242, 7243, 7244, 7245, 7246, 7247, 7248, 7249, 7250, 7251, 7252, 7253, 7254, 7255, 7256, 7257, 7258, 7259,
    7260, 7261, 7262, 7263, 7264, 7265, 7266, 7267, 7268, 7269, 7270, 7271, 7272, 7273, 7274, 7275, 7276, 7277, 7278, 7279, 7280, 7281, 7282, 7283, 7284, 7285, 7286, 7287, 7288, 7289, 7290, 7291,
    7292, 7293, 7294, 7295, 7296, 7297, 7298, 7299, 7300, 7301, 7302, 7303, 7304, 7305, 7306, 7307, 7308, 7309, 7310, 7311, 7312, 7313, 7314, 7315, 7316, 7317, 7318, 7319, 7320, 7321, 7322, 7323,
    7324, 7325, 7326, 7327, 7328, 7329, 7330, 7331, 7332, 7333, 7334, 7335, 7336, 7337, 7338, 7339, 7340, 7341, 7342, 7343, 7344, 7345, 7346, 7347, 7348, 7349, 7350, 7351, 7352, 7353, 7354, 7355,
    7356, 7357, 7358, 7359, 7360, 7361, 7362, 7363, 7364, 7365, 7366, 7367, 7368, 7369, 7370, 7371, 7372, 7373, 7374, 7375, 7376, 7377, 7378, 7379, 7380, 7381, 7382, 7383, 7384, 7385, 7386, 7387,
    7388, 7389, 7390, 7391, 7392, 7393, 7394, 7395, 7396, 7397, 7398, 7399, 7400, 7401, 7402, 7403, 7404, 7405, 7406, 7407, 7408, 7409, 7410, 7411, 7412, 7413, 7414, 7415, 7416, 7417, 7418, 7419,
    7420, 7421, 7422, 7423, 7424, 7425, 7426, 7427, 7428, 7429, 7430, 7431, 7432, 7433, 7434, 7435, 7436, 7437, 7438, 7439, 7440, 7441, 7442, 7443, 7444, 7445, 7446, 7447, 7448, 7449, 7450, 7451,
    7452, 7453, 7454, 7455, 7456, 7457, 7458, 7459, 7460, 7461, 7462, 7463, 7464, 7465, 7466, 7467, 7468, 7469, 7470, 7471, 7472, 7473, 7474, 7475, 7476, 7477, 7478, 7479, 7480, 7481, 7482, 7483,
    7484, 7485, 7486, 7487, 7488, 7489, 7490, 7491, 7492, 7493, 7494, 7495, 7496, 7497, 7498, 7499, 7500, 7501, 7502, 7503, 7504, 7505, 7506, 7507, 7508, 7509, 7510, 7511, 7512, 7513, 7514, 7515,
    7516, 7517, 7518, 7519, 7520, 7521, 7522, 7523, 7524, 7525, 7526, 7527, 7528, 7529, 7530, 7531, 7532, 7533, 7534, 7535, 7536, 7537, 7538, 7539, 7540, 7541, 7542, 7543, 7544, 7545, 7546, 7547,
    7548, 7549, 7550, 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558, 7559, 7560, 7561, 7562, 7563, 7564, 7565, 7566, 7567, 7568, 7569, 7570, 7571, 7572, 7573, 7574, 7575, 7576, 7577, 7578, 7579,
    7580, 7581, 7582, 7583, 7584, 7585, 7586, 7587, 7588, 7589, 7590, 7591, 7592, 7593, 7594, 7595, 7596, 7597, 7598, 7599, 7600, 7601, 7602, 7603, 7604, 7605, 7606, 7607, 7608, 7609, 7610, 7611,
    7612, 7613, 7614, 7615, 7616, 7617, 7618, 7619, 7620, 7621, 7622, 7623, 7624, 7625, 7626, 7627, 7628, 7629, 7630, 7631, 7632, 7633, 7634, 7635, 7636, 7637, 7638, 7639, 7640, 7641, 7642, 7643,
    7644, 7645, 7646, 7647, 7648, 7649, 7650, 7651, 7652, 7653, 7654, 7655, 7656, 7657, 7658, 7659, 7660, 7661, 7662, 7663, 7664, 7665, 7666, 7667, 7668, 7669, 7670, 7671, 7672, 7673, 7674, 7675,
    7676, 7677, 7678, 7679, 7680, 7681, 7682, 7683, 7684, 7685, 7686, 7687, 7688, 7689, 7690, 7691, 7692, 7693, 7694, 7695, 7696, 7697, 7698, 7699, 7700, 7701, 7702, 7703, 7704, 7705, 7706, 7707,
    7708, 7709, 7710, 7711, 7712, 7713, 7714, 7715, 7716, 7717, 7718, 7719, 7720, 7721, 7722, 7723, 7724, 7725, 7726, 7727, 7728, 7729, 7730, 7731, 7732, 7733, 7734, 7735, 7736, 7737, 7738, 7739,
    7740, 7741, 7742, 7743, 7744, 7745, 7746, 7747, 7748, 7749, 7750, 7751, 7752, 7753, 7754, 7755, 7756, 7757, 7758, 7759, 7760, 7761, 7762, 7763, 7764, 7765, 7766, 7767, 7768, 7769, 7770, 7771,
    7772, 7773, 7774, 7775, 7776, 7777, 7778, 7779, 7780, 7781, 7782, 7783, 7784, 7785, 7786, 7787, 7788, 7789, 7790, 7791, 7792, 7793, 7794, 7795, 7796, 7797, 7798, 7799, 7800, 7801, 7802, 7803,
    7804, 7805, 7806, 7807, 7808, 7809, 7810, 7811, 7812, 7813, 7814, 7815, 7816, 7817, 7818, 7819, 7820, 7821, 7822, 7823, 7824, 7825, 7826, 7827, 7828, 7829, 7830, 7831, 7832, 7833, 7834, 7835,
    7836, 7837, 7838, 7839, 7840, 7841, 7842, 7843, 7844, 7845, 7846, 7847, 7848, 7849, 7850, 7851, 7852, 7853, 7854, 7855, 7856, 7857, 7858, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7866, 7867,
    7868, 7869, 7870, 7871, 7872, 7873, 7874, 7875, 7876, 7877, 7878, 7879, 7880, 7881, 7882, 7883, 7884, 7885, 7886, 7887, 7888, 7889, 7890, 7891, 7892, 7893, 7894, 7895, 7896, 7897, 7898, 7899,
    7900, 7901, 7902, 7903, 7904, 7905, 7906, 7907, 7908, 7909, 7910, 7911, 7912, 7913, 7914, 7915, 7916, 7917, 7918, 7919, 7920, 7921, 7922, 7923, 7924, 7925, 7926, 7927, 7928, 7929, 7930, 7931,
    7932, 7933, 7934, 7935, 7936, 7937, 7938, 7939, 7940, 7941, 7942, 7943, 7944, 7945, 7946, 7947, 7948, 7949, 7950, 7951, 7952, 7953, 7954, 7955, 7956, 7957, 7958, 7959, 7960, 7961, 7962, 7963,
    7964, 7965, 7966, 7967, 7968, 7969, 7970, 7971, 7972, 7973, 7974, 7975, 7976, 7977, 7978, 7979, 7980, 7981, 7982, 7983, 7984, 7985, 7986, 7987, 7988, 7989, 7990, 7991, 7992, 7993, 7994, 7995,
    7996, 7997, 7998, 7999, 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009, 8010, 8011, 8012, 8013, 8014, 8015, 8016, 8017, 8018, 8019, 8020, 8021, 8022, 8023, 8024, 8025, 8026, 8027,
    8028, 8029, 8030, 8031, 8032, 8033, 8034, 8035, 8036, 8037, 8038, 8039, 8040, 8041, 8042, 8043, 8044, 8045, 8046, 8047, 8048, 8049, 8050, 8051, 8052, 8053, 8054, 8055, 8056, 8057, 8058, 8059,
    8060, 8061, 8062, 8063, 8064, 8065, 8066, 8067, 8068, 8069, 8070, 8071, 8072, 8073, 8074, 8075, 8076, 8077, 8078, 8079, 8080, 8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, 8090, 8091,
    8092, 8093, 8094, 8095, 8096, 8097, 8098, 8099, 8100, 8101, 8102, 8103, 8104, 8105, 8106, 8107, 8108, 8109, 8110, 8111, 8112, 8113, 8114, 8115, 8116, 8117, 8118, 8119, 8120, 8121, 8122, 8123,
    8124, 8125, 8126, 8127, 8128, 8129, 8130, 8131, 8132, 8133, 8134, 8135, 8136, 8137, 8138, 8139, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155,
    8156, 8157, 8158, 8159, 8160, 8161, 8162, 8163, 8164, 8165, 8166, 8167, 8168, 8169, 8170, 8171, 8172, 8173, 8174, 8175, 8176, 8177, 8178, 8179, 8180, 8181, 8182, 8183, 8184, 8185, 8186, 8187,
    8188, 8189, 8190, 8191, 8191, 8190, 8189, 8188, 8187, 8186, 8185, 8184, 8183, 8182, 8181, 8180, 8179, 8178, 8177, 8176, 8175, 8174, 8173, 8172, 8171, 8170, 8169, 8168, 8167, 8166, 8165, 8164,
    8163, 8162, 8161, 8160, 8159, 8158, 8157, 8156, 8155, 8154, 8153, 8152, 8151, 8150, 8149, 8148, 8147, 8146, 8145, 8144, 8143, 8142, 8141, 8140, 8139, 8138, 8137, 8136, 8135, 8134, 8133, 8132,
    8131, 8130, 8129, 8128, 8127, 8126, 8125, 8124, 8123, 8122, 8121, 8120, 8119, 8118, 8117, 8116, 8115, 8114, 8113, 8112, 8111, 8110, 8109, 8108, 8107, 8106, 8105, 8104, 8103, 8102, 8101, 8100
};

static tab_s16 *tbl_plps_ext = tbl_plps + (1 << 13);

static int ec_write_rpl(bs_t *bs, com_rpl_t *rpl)
{
    int ddoi_base = 0;
    bs_write_ue(bs, (u32)rpl->num);

    if (rpl->num > 0) {
        bs_write_ue(bs, (u32)abs(rpl->delta_doi[0]));
        if (rpl->delta_doi[0] != 0) {
            bs_write1(bs, rpl->delta_doi[0] < 0);
        }
        ddoi_base = rpl->delta_doi[0];
    }
    for (int i = 1; i < rpl->num; ++i) {
        int deltaRefPic = rpl->delta_doi[i] - ddoi_base;
        bs_write_ue(bs, (u32)abs(deltaRefPic));
        if (deltaRefPic != 0) {
            bs_write1(bs, deltaRefPic < 0);
        }
        ddoi_base = rpl->delta_doi[i];
    }
    return COM_OK;
}

static void ec_write_wq_matrix(bs_t *bs, u8 *m4x4, u8 *m8x8)
{
    int i;
    for (i = 0; i < 16; i++) {
        bs_write_ue(bs, m4x4[i]);
    }
    for (i = 0; i < 64; i++) {
        bs_write_ue(bs, m8x8[i]);
    }
}

int ec_write_sqh(bs_t *bs, com_seqh_t *sqh)
{
    bs_write (bs, 0x000001, 24);
    bs_write (bs, 0xB0, 8);

    bs_write (bs, sqh->profile_id, 8);
    bs_write (bs, sqh->level_id, 8);
    bs_write1(bs, sqh->progressive_sequence);
    bs_write1(bs, sqh->field_coded_sequence);

    bs_write1(bs, 0); // library_stream_flag
    bs_write1(bs, 0); // library_picture_enable_flag

    bs_write1(bs, 1); // marker_bit
    bs_write (bs, sqh->horizontal_size, 14);
    bs_write1(bs, 1); // marker_bit
    bs_write (bs, sqh->vertical_size, 14);
    bs_write (bs, sqh->chroma_format, 2);
    bs_write (bs, sqh->sample_precision, 3);

    if (sqh->profile_id == 0x22) {
        bs_write(bs, sqh->encoding_precision, 3);
    }
    bs_write1(bs, 1); // marker_bit
    bs_write (bs, sqh->aspect_ratio, 4);
    bs_write (bs, sqh->frame_rate_code, 4);
    bs_write1(bs, 1); // marker_bit
    bs_write (bs, sqh->bit_rate_lower, 18);
    bs_write1(bs, 1); // marker_bit
    bs_write (bs, sqh->bit_rate_upper, 12);
    bs_write1(bs, sqh->low_delay);

    bs_write1(bs, sqh->temporal_id_enable_flag);
    bs_write1(bs, 1); // marker_bit
    bs_write (bs, sqh->bbv_buffer_size, 18);
    bs_write1(bs, 1); // marker_bit
    bs_write (bs, sqh->max_dpb_size - 1, 4);

    bs_write1(bs, (u32)sqh->rpl1_index_exist_flag);
    bs_write1(bs, (u32)sqh->rpl1_same_as_rpl0_flag);
    bs_write1(bs, 1); // marker_bit

    bs_write_ue(bs, (u32)sqh->rpls_l0_num);

    for (int i = 0; i < sqh->rpls_l0_num; ++i) {
        ec_write_rpl(bs, &sqh->rpls_l0[i]);
    }
    if (!sqh->rpl1_same_as_rpl0_flag) {
        bs_write_ue(bs, (u32)sqh->rpls_l1_num);
        for (int i = 0; i < sqh->rpls_l1_num; ++i) {
            ec_write_rpl(bs, &sqh->rpls_l1[i]);
        }
    }

    sqh->active_ref_minus1[0] = 1;
    sqh->active_ref_minus1[1] = 1;
    bs_write_ue(bs, sqh->active_ref_minus1[0]); 
    bs_write_ue(bs, sqh->active_ref_minus1[1]);

    bs_write (bs, sqh->log2_max_cuwh - 2,      3);
    bs_write (bs, com_tbl_log2[sqh->min_cu_size] - 2,     2);
             
    bs_write (bs, com_tbl_log2[sqh->max_part_ratio] - 2,  2);
    bs_write (bs, sqh->max_split_times - 6,               3);
    bs_write (bs, com_tbl_log2[sqh->min_qt_size] - 2,     3);
    bs_write (bs, com_tbl_log2[sqh->max_bt_size] - 2,     3);
             
    bs_write (bs, com_tbl_log2[sqh->max_eqt_size] - 3,     2);
    bs_write1(bs, 1); // marker_bit

    bs_write1(bs, sqh->wq_enable);

    if (sqh->wq_enable) {
        bs_write1(bs, sqh->seq_wq_mode);

        if (sqh->seq_wq_mode) {
            ec_write_wq_matrix(bs, sqh->wq_4x4_matrix, sqh->wq_8x8_matrix);
        }
    }

    bs_write1(bs, sqh->sectrans_enable);
    bs_write1(bs, sqh->sao_enable);
    bs_write1(bs, sqh->alf_enable);
    bs_write1(bs, sqh->affine_enable);

    bs_write1(bs, sqh->smvd_enable);

    bs_write1(bs, sqh->ipcm_enable_flag);
    bs_write1(bs, sqh->amvr_enable);
    bs_write (bs, sqh->num_of_hmvp, 4); // 1~ 15
    bs_write1(bs, sqh->umve_enable);

    if (sqh->amvr_enable && sqh->num_of_hmvp) {
        bs_write1(bs, sqh->emvr_enable);
    }
    bs_write1(bs, sqh->ipf_enable_flag);
    bs_write1(bs, sqh->tscpm_enable);

    bs_write1(bs, 1); // marker_bit

    bs_write1(bs, sqh->dt_enable);
    if (sqh->dt_enable) {
        bs_write(bs, com_tbl_log2[sqh->max_dt_size] - 4, 2);
    }
    bs_write1(bs, sqh->pbt_enable);
    if (sqh->low_delay == 0) {
        bs_write(bs, sqh->output_reorder_delay, 5);
    }

    bs_write1(bs, sqh->filter_cross_patch);
    bs_write1(bs, sqh->colocated_patch);
    bs_write1(bs, 1); // patch_stable
    bs_write1(bs, 1); // patch_uniform
    bs_write1(bs, 1); // marker_bit
    bs_write_ue(bs, sqh->patch_width  - 1);
    bs_write_ue(bs, sqh->patch_height - 1);

    bs_write(bs, 0, 2);// reserve bit

    bs_write1(bs, 1);// stuffing bit

    while (!IS_BYTE_ALIGN(bs)) {
        bs_write1(bs, 0);
    }
    return COM_OK;
}

void bs_demulate(bs_t *bs)
{
    unsigned int zero_cnt = 0;
    unsigned char start_code;
    unsigned int start_idx = 0;
    u8 *dst;

    bs_flush(bs);

    unsigned int current_bytes_size = BS_GET_BYTES(bs);
    if (bs->start[start_idx] == 0x00 && bs->start[start_idx + 1] == 0x00 && bs->start[start_idx + 2] == 0x01) {
        start_idx += 3;
        start_code = bs->start[start_idx++]; 
        if (start_code == 0x00) {
            zero_cnt++;
        }
    } else {
        printf("Wrong start code!");
        exit(1);
    }

    unsigned int write_idx = start_idx;
    unsigned int bits_offset = 0;

    switch (start_code) {
    case 0xb5:
        if ((bs->start[start_idx] >> 4) == 0x0d) {
            break;
        } else {
        }
    case 0xb0: 
    case 0xb2: 
        return;
    default:
        break;
    }

    /* write head info*/
    dst = bs->buftmp;

    *dst++ = 0x00;
    *dst++ = 0x00;
    *dst++ = 0x01;
    *dst++ = start_code;

    /*demulate*/
    for (unsigned int idx = start_idx; idx < current_bytes_size; idx++) {
        unsigned char c = (bs->start[idx - 1] << (8 - bits_offset)) | (bs->start[idx] >> bits_offset);
        if (2 <= zero_cnt && 0 == (c & 0xfc)) {
            *dst++ = 0x02;
            bits_offset += 2;
            zero_cnt = 0;
            if (bits_offset >= 8) {
                bits_offset = 0;
                idx--;
            }
            continue;
        }
        *dst++ = c;

        if (0 == c) {
            zero_cnt++;
        } else {
            zero_cnt = 0;
        }
    }

    if (bits_offset != 0) {
        /*get the last several bits*/
        unsigned char  c = bs->start[current_bytes_size - 1] << (8 - bits_offset);
        *dst++ = c;
    }

    write_idx = (int)(dst - bs->buftmp);
    memcpy(bs->start, bs->buftmp, write_idx);

    int stuffbitnum = 8 - bits_offset % 8;

    if (stuffbitnum == 8) {
        stuffbitnum = 0;
    }
    if (stuffbitnum > 0) {
        bs->start[write_idx - 1] = bs->start[write_idx - 1] & (~(1 << (8 - stuffbitnum))) << stuffbitnum;
        bs->start[write_idx - 1] = bs->start[write_idx - 1] | (1 << (stuffbitnum - 1));
        bs->cur = bs->start + write_idx;
        bs->code = 0;
        bs->leftbits = 32;
    } else {
        bs->cur = bs->start + write_idx;
        bs->code = 0;
        bs->leftbits = 32;
    }
}

static void ec_write_alf_coef(bs_t *bs, com_alf_pic_param_t *Alfp)
{
    int pos, i;
    int groupIdx[NO_VAR_BINS];
    int f = 0;
    const int numCoeff = (int)ALF_MAX_NUM_COEF;
    unsigned int noFilters;
    switch (Alfp->componentID) {
    case U_C:
    case V_C: {
        for (pos = 0; pos < numCoeff; pos++) {
            bs_write_se(bs, Alfp->coeffmulti[0][pos]);
        }
    }
    break;
    case Y_C: {
        noFilters = Alfp->filters_per_group - 1;
        bs_write_ue(bs, noFilters); 
        groupIdx[0] = 0;
        f++;
        if (Alfp->filters_per_group > 1) {
            for (i = 1; i < NO_VAR_BINS; i++) {
                if (Alfp->filterPattern[i] == 1) {
                    groupIdx[f] = i;
                    f++;
                }
            }
        }
        for (f = 0; f < Alfp->filters_per_group; f++) {
            if (f > 0 && Alfp->filters_per_group != 16) {
                bs_write_ue(bs, (unsigned int)(groupIdx[f] - groupIdx[f - 1]));
            }
            for (pos = 0; pos < numCoeff; pos++) {
                bs_write_se(bs, Alfp->coeffmulti[f][pos]);
            }
        }
    }
    break;
    default: {
        printf("Not a legal component ID\n");
        assert(0);
        exit(-1);
    }
    }
}

int ec_write_pichdr(bs_t *bs, com_pic_header_t *pichdr, com_seqh_t *sqh, com_pic_t *pic)
{
    bs_write(bs, 0x000001, 24);
    bs_write(bs, pichdr->slice_type == SLICE_I ? 0xB3 : 0xB6, 8);

    if (pichdr->slice_type != SLICE_I) {
        bs_write1(bs, pichdr->random_access_decodable_flag);
    }

    bs_write(bs, pichdr->bbv_delay >> 24, 8);
    bs_write(bs, (pichdr->bbv_delay & 0x00ff0000) >> 16, 8);
    bs_write(bs, (pichdr->bbv_delay & 0x0000ff00) >> 8, 8);
    bs_write(bs, pichdr->bbv_delay & 0xff, 8);

    if (pichdr->slice_type != SLICE_I) {
        assert(pichdr->slice_type == SLICE_P || pichdr->slice_type == SLICE_B);
        bs_write(bs, pichdr->slice_type == SLICE_B ? 2 : 1, 2);
    } else {
        bs_write1(bs, pichdr->time_code_flag);
        if (pichdr->time_code_flag == 1) {
            bs_write(bs, pichdr->time_code, 24);
        }
    }

    bs_write(bs, pichdr->dtr % DOI_CYCLE_LENGTH, 8); 

    if (sqh->temporal_id_enable_flag == 1) {
        bs_write(bs, pic->layer_id, 3);
    }
    if (sqh->low_delay == 0) {
        bs_write_ue(bs, pichdr->picture_output_delay);
    }
    if (sqh->low_delay == 1) {
        bs_write_ue(bs, pichdr->bbv_check_times);
    }

    bs_write1(bs, pichdr->progressive_frame);
    assert(pichdr->progressive_frame == 1);

    if (pichdr->progressive_frame == 0) {
        bs_write1(bs, pichdr->picture_structure);
    } else {
        assert(pichdr->picture_structure == 1);
    }
    bs_write1(bs, pichdr->top_field_first);
    bs_write1(bs, pichdr->repeat_first_field);
    if (sqh->field_coded_sequence == 1) {
        bs_write1(bs, pichdr->top_field_picture_flag);
        bs_write1(bs, 0); // reserved_bits
    }

    bs_write1(bs, pichdr->ref_pic_list_sps_flag[0]);

    if (pichdr->ref_pic_list_sps_flag[0]) {
        if (sqh->rpls_l0_num > 1) {
            bs_write_ue(bs, pichdr->rpl_l0_idx);
        } else if (sqh->rpls_l0_num == 1) {
            assert(pichdr->rpl_l0_idx == 0);
        } else {
            return COM_ERR; 
        }
    } else {
        ec_write_rpl(bs, &pichdr->rpl_l0);
    }

    if (sqh->rpl1_index_exist_flag) {
        bs_write1(bs, pichdr->ref_pic_list_sps_flag[1]);
    }
    if (pichdr->ref_pic_list_sps_flag[1]) {
        if (sqh->rpls_l1_num > 1 && sqh->rpl1_index_exist_flag) {
            bs_write_ue(bs, pichdr->rpl_l1_idx);
        } else if (!sqh->rpl1_index_exist_flag) {
            assert(pichdr->rpl_l1_idx == pichdr->rpl_l0_idx);
        } else if (sqh->rpls_l1_num == 1) {
            assert(pichdr->rpl_l1_idx == 0);
        } else {
            return COM_ERR; 
        }
    } else {
        ec_write_rpl(bs, &pichdr->rpl_l1);
    }

    if (pichdr->slice_type != SLICE_I) {
        bs_write1(bs, 1); // num_ref_idx_active_override_flag
        bs_write_ue(bs, (u32)(pichdr->rpl_l0).active - 1);
        if (pichdr->slice_type == SLICE_B) {
            bs_write_ue(bs, (u32)(pichdr->rpl_l1).active - 1);
        }
    }

    bs_write1(bs, pichdr->fixed_picture_qp_flag);
    bs_write(bs, pic->picture_qp, 7);

    if (pichdr->slice_type != SLICE_I && !(pichdr->slice_type == SLICE_B && pichdr->picture_structure == 1)) {
        bs_write1(bs, 0);
    }

    bs_write1(bs, pichdr->loop_filter_disable_flag);
    if (pichdr->loop_filter_disable_flag == 0) {
        bs_write(bs, pichdr->loop_filter_parameter_flag, 1);
        if (pichdr->loop_filter_parameter_flag) {
            bs_write_se(bs, pichdr->alpha_c_offset);
            bs_write_se(bs, pichdr->beta_offset);
        } else {
            pichdr->alpha_c_offset = 0;
            pichdr->beta_offset = 0;
        }
    }

    bs_write1(bs, pichdr->chroma_quant_param_disable_flag);

    if (pichdr->chroma_quant_param_disable_flag == 0) {
        bs_write_se(bs, pichdr->chroma_quant_param_delta_cb);
        bs_write_se(bs, pichdr->chroma_quant_param_delta_cr);
    }

    if (sqh->wq_enable) {
        bs_write1(bs, pichdr->pic_wq_enable);
        if (pichdr->pic_wq_enable) {
            bs_write(bs, pichdr->pic_wq_data_idx, 2);
            if (pichdr->pic_wq_data_idx == 2) {
                ec_write_wq_matrix(bs, pichdr->wq_4x4_matrix, pichdr->wq_8x8_matrix);
            } else if (pichdr->pic_wq_data_idx == 1) {
                int i;

                bs_write1(bs, 0); 
                bs_write(bs, pichdr->wq_param, 2);
                bs_write(bs, pichdr->wq_model, 2);

                if (pichdr->wq_param == 1) {
                    for (i = 0; i < 6; i++) {
                        bs_write_se(bs, pichdr->wq_param_vector[i] - com_tbl_wq_default_param[0][i]);
                    }
                } else if (pichdr->wq_param == 2) {
                    for (i = 0; i < 6; i++) {
                        bs_write_se(bs, pichdr->wq_param_vector[i] - com_tbl_wq_default_param[1][i]);
                    }
                }
            }
        }
    }

    if (pichdr->tool_alf_on) {
        int *pic_alf_on = pichdr->pic_alf_on;
        com_alf_pic_param_t *alfPictureParam = pichdr->m_alfPictureParam;

        bs_write(bs, pic_alf_on[Y_C], 1);
        bs_write(bs, pic_alf_on[U_C], 1);
        bs_write(bs, pic_alf_on[V_C], 1);

        if (pic_alf_on[Y_C] || pic_alf_on[U_C] || pic_alf_on[V_C]) {
            for (int compIdx = 0; compIdx < N_C; compIdx++) {
                if (pic_alf_on[compIdx]) {
                    ec_write_alf_coef(bs, &alfPictureParam[compIdx]);
                }
            }
        }
    }

    if (pichdr->slice_type != SLICE_I && sqh->affine_enable) {
        bs_write(bs, pichdr->affine_subblk_size_idx, 1);
    }

    bs_write1(bs, 1);// stuffing bit

    while (!IS_BYTE_ALIGN(bs)) {
        bs_write1(bs, 0);
    }
    bs_demulate(bs);
    return COM_OK;
}

int ec_write_patch_hdr(bs_t *bs, com_seqh_t *sqh, com_pic_header_t *ph, com_patch_header_t *sh, u8 patch_idx)
{
    bs_write(bs, 0x000001, 24);
    bs_write(bs, patch_idx, 8);

    if (!ph->fixed_picture_qp_flag) {
        bs_write1(bs, sh->fixed_slice_qp_flag);
        bs_write(bs, sh->slice_qp, 7);
    }
    if (sqh->sao_enable) {
        bs_write1(bs, sh->slice_sao_enable[Y_C]);
        bs_write1(bs, sh->slice_sao_enable[U_C]);
        bs_write1(bs, sh->slice_sao_enable[V_C]);
    }
    /* byte align */
    while (!IS_BYTE_ALIGN(bs)) {
        bs_write1(bs, 1);
    }
    return COM_OK;
}

int ec_write_patch_end(bs_t *bs)
{
    bs_write(bs, 0x000001, 24);
    bs_write(bs, 0x8F, 8);
    return COM_OK;
}

static void bs_write_est(lbac_t *lbac, int len)
{
    lbac->bitcounter += len;
}

static void put_byte(u8 writing_byte, lbac_t *lbac, bs_t *bs)
{
    if (lbac->is_pending_byte) {
        bs_write(bs, lbac->pending_byte, 8);
    }
    lbac->pending_byte = writing_byte;
    lbac->is_pending_byte = 1;
}

static void carry_propagate(lbac_t *lbac, bs_t *bs)
{
    u32 leadByte = (lbac->code) >> (24 - lbac->left_bits);
    lbac->left_bits += 8;
    (lbac->code) &= (0xffffffffu >> lbac->left_bits);
    if (leadByte < 0xFF) {
        while (lbac->stacked_ff != 0) {
            put_byte(0xFF, lbac, bs);
            lbac->stacked_ff--;
        }
        put_byte((u8)leadByte, lbac, bs);
    } else if (leadByte > 0xFF) {
        lbac->pending_byte++; //! add carry bit to pending_byte
        while (lbac->stacked_ff != 0) {
            put_byte(0x00, lbac, bs); //! write pending_tyte
            lbac->stacked_ff--;
        }
        put_byte((u8)leadByte & 0xFF, lbac, bs);
    } else { //! leadByte == 0xff
        lbac->stacked_ff++;
    }
}

static avs3_always_inline int get_shift(int v)
{
#ifdef _WIN32
    unsigned long index;
    _BitScanReverse(&index, v);
    return 8 - index;
#else
    return __builtin_clz(v) - 23;
#endif
}

void lbac_ctx_init(com_lbac_all_ctx_t *lbac_ctx)
{
    com_mset(lbac_ctx, 0x00, sizeof(*lbac_ctx));

    /* Initialization of the context models */
    int num = sizeof(com_lbac_all_ctx_t) / sizeof(lbac_ctx_model_t);
    lbac_ctx_model_t *p = (lbac_ctx_model_t *)lbac_ctx;

    for (int i = 0; i < num; i++) {
        p[i] = PROB_INIT;
    }
}

void lbac_reset(lbac_t *lbac)
{
    lbac->range           = 0x1FF;
    lbac->code            = 0;
    lbac->left_bits       = 23;
    lbac->pending_byte    = 0;
    lbac->is_pending_byte = 0;
    lbac->stacked_ff      = 0;
}

void lbac_finish(lbac_t *lbac, bs_t *bs)
{
    if (lbac->code >> (32 - lbac->left_bits)) {
        assert(lbac->pending_byte != 0xff);
        bs_write(bs, lbac->pending_byte + 1, 8);
        while (lbac->stacked_ff != 0) {
            bs_write(bs, 0x00, 8);
            lbac->stacked_ff--;
        }
        lbac->code -= 1 << (32 - lbac->left_bits);
    } else {
        if (lbac->is_pending_byte) {
            bs_write(bs, lbac->pending_byte, 8);
        }
        while (lbac->stacked_ff != 0) {
            bs_write(bs, 0xFF, 8);
            lbac->stacked_ff--;
        }
    }
    lbac->code |= (1 << 7);
    bs_write(bs, lbac->code >> 8, 24 - lbac->left_bits);

    if ((24 - lbac->left_bits) % 8) {
        bs_write(bs, lbac->code, 8);
    }

    bs_write(bs, 1, 1);

    while (!IS_BYTE_ALIGN(bs)) {
        bs_write(bs, 0, 1);
    }
}

u32 lbac_get_bits(lbac_t *lbac)
{
    return lbac->bitcounter + 8 * (lbac->stacked_ff + (lbac->is_pending_byte ? 1 : 0)) + 23 - lbac->left_bits;
}

void lbac_encode_bin(u32 bin, lbac_t *lbac, lbac_ctx_model_t *model, bs_t *bs)
{
    u16 cmps = (*model) & 1;
    u32 rLPS = ((*model) & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1);
    u32 rMPS = lbac->range - rLPS;
    int s_flag = rMPS < QUAR_HALF_PROB;
    rMPS |= 0x100;

    if (bs == NULL) {
        if (bin == cmps) { // MPS
            lbac->bitcounter += s_flag;
            lbac->range = rMPS;
            *model = tbl_plps[*model];
        } else {
            rLPS = (lbac->range << s_flag) - rMPS;
            int shift = get_shift(rLPS);
            lbac->range = rLPS << shift;
            lbac->bitcounter += shift + s_flag;
            *model = tbl_plps_ext[*model];
        }
    } else {
        if (bin == cmps) { // MPS
            if (s_flag) {
                lbac->code <<= 1;
                if (--lbac->left_bits < 12) {
                    carry_propagate(lbac, bs);
                }
            }
            lbac->range = rMPS;
            *model = tbl_plps[*model];
        } else {
            rLPS = (lbac->range << s_flag) - rMPS;
            int shift = get_shift(rLPS);
            lbac->range = rLPS << shift;
            lbac->code = ((lbac->code << s_flag) + rMPS) << shift;
            lbac->left_bits -= (shift + s_flag);
            if (lbac->left_bits < 12) {
                carry_propagate(lbac, bs);
            }
            *model = tbl_plps_ext[*model];
        }
    }
}

void lbac_encode_binW(u32 bin, lbac_t *lbac, lbac_ctx_model_t *model1, lbac_ctx_model_t *model2, bs_t *bs)
{
    u16 prob_lps;
    u16 prob_lps1 = ((*model1) & PROB_MASK) >> 1;
    u16 prob_lps2 = ((*model2) & PROB_MASK) >> 1;
    u16 cmps;
    u16 cmps1 = (*model1) & 1;
    u16 cmps2 = (*model2) & 1;
    u32 rLPS;
    u32 rMPS;
    int s_flag;

    if (cmps1 == cmps2) {
        cmps = cmps1;
        prob_lps = (prob_lps1 + prob_lps2) >> 1;
    } else {
        if (prob_lps1 < prob_lps2) {
            cmps = cmps1;
            prob_lps = (256 << LG_PMPS_SHIFTNO) - 1 - ((prob_lps2 - prob_lps1) >> 1);
        } else {
            cmps = cmps2;
            prob_lps = (256 << LG_PMPS_SHIFTNO) - 1 - ((prob_lps1 - prob_lps2) >> 1);
        }
    }

    rLPS = prob_lps >> LG_PMPS_SHIFTNO;

    rMPS = lbac->range - rLPS;
    s_flag = rMPS < QUAR_HALF_PROB;
    rMPS |= 0x100;

    if (bs == NULL) {
        if (bin == cmps) { // MPS
            lbac->bitcounter += s_flag;
            lbac->range = rMPS;
        } else {
            rLPS = (lbac->range << s_flag) - rMPS;
            int shift = get_shift(rLPS);
            lbac->range = rLPS << shift;
            lbac->bitcounter += shift + s_flag;
        }
    } else {
        if (bin == cmps) { // MPS
            if (s_flag) {
                lbac->code <<= 1;
                if (--lbac->left_bits < 12) {
                    carry_propagate(lbac, bs);
                }
            }
            lbac->range = rMPS;
        } else {
            rLPS = (lbac->range << s_flag) - rMPS;
            int shift = get_shift(rLPS);
            lbac->range = rLPS << shift;
            lbac->code = ((lbac->code << s_flag) + rMPS) << shift;
            lbac->left_bits -= (shift + s_flag);
            if (lbac->left_bits < 12) {
                carry_propagate(lbac, bs);
            }
        }
    }
    if (bin != cmps1) {
        *model1 = tbl_plps_ext[*model1];
    } else {
        *model1 = tbl_plps[*model1];
    }
    if (bin != cmps2) {
        *model2 = tbl_plps_ext[*model2];
    } else {
        *model2 = tbl_plps[*model2];
    }
}

void lbac_encode_bin_trm(u32 bin, lbac_t *lbac, bs_t *bs)
{
    int s_flag = (lbac->range == QUAR_HALF_PROB);
    u32 rMPS = (lbac->range - 1) | 0x100;
    lbac->range -= 2;

    if (bs == NULL) {
        if (!bin) { // MPS
            lbac->bitcounter += s_flag;
            lbac->range = rMPS;
        } else {
            lbac->range = QUAR_HALF_PROB;
            lbac->bitcounter += 8 + s_flag;
        }
    } else {
        if (!bin) { // MPS
            if (s_flag) {
                lbac->code <<= 1;
                if (--lbac->left_bits < 12) {
                    carry_propagate(lbac, bs);
                }
            }
            lbac->range = rMPS;
        } else {
            lbac->range = QUAR_HALF_PROB;
            lbac->code = ((lbac->code << s_flag) + rMPS) << 8;
            lbac->left_bits -= (8 + s_flag);
            if (lbac->left_bits < 12) {
                carry_propagate(lbac, bs);
            }
        }
    }
}

static void lbac_encode_bin_ep(u32 bin, lbac_t *lbac, bs_t *bs)
{
    if (bs == NULL) {
        lbac->bitcounter++;
    } else {
        lbac->code <<= 1;
        if (bin) {
            lbac->code += lbac->range;
        }
        if (--(lbac->left_bits) < 12) {
            carry_propagate(lbac, bs);
        }
    }
}

static void lbac_write_unary_sym_ep(u32 sym, lbac_t *lbac, bs_t *bs)
{
    if (bs == NULL) {
        lbac->bitcounter += sym + 1;
    } else {
        do {
            lbac->code <<= 1;
            if (sym ? 0 : 1) {
                lbac->code += lbac->range;
            }
            if (--(lbac->left_bits) < 12) {
                carry_propagate(lbac, bs);
            }
        } while (sym--);
    }
}

static void lbac_write_truncate_unary_sym(u32 sym, u32 num_ctx, u32 max_num, lbac_t *lbac, lbac_ctx_model_t *model_base, bs_t *bs)
{
    u32 ctx_idx = 0;

    if (bs == NULL) {
        do {
            lbac_ctx_model_t *model = model_base + COM_MIN(ctx_idx, num_ctx - 1);
            u16 cmps = (*model) & 1;
            u32 rLPS = ((*model) & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1);
            u32 rMPS = lbac->range - rLPS;
            int s_flag = rMPS < QUAR_HALF_PROB;
            rMPS |= 0x100;

            if (sym ? !cmps : cmps) { // MPS
                lbac->bitcounter += s_flag;
                lbac->range = rMPS;
                *model = tbl_plps[*model];
            } else {
                rLPS = (lbac->range << s_flag) - rMPS;
                int shift = get_shift(rLPS);
                lbac->range = rLPS << shift;
                lbac->bitcounter += shift + s_flag;
                *model = tbl_plps_ext[*model];
            }
        } while (++ctx_idx < max_num - 1 && sym--);
    } else {
        do {
            lbac_encode_bin(sym ? 0 : 1, lbac, model_base + COM_MIN(ctx_idx, num_ctx - 1), bs);
        } while (++ctx_idx < max_num - 1 && sym--);
    }
}

static void lbac_encode_bins_msb(u32 value, int num_bin, lbac_t *lbac, lbac_ctx_model_t *model, bs_t *bs)
{
    if (bs == NULL) {
        for (int i = num_bin - 1; i >= 0; i--, model++) {
            u32 rLPS = ((*model) & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1);
            u32 rMPS = lbac->range - rLPS;
            int s_flag = rMPS < QUAR_HALF_PROB;
            rMPS |= 0x100;

            if (!(((value >> i) ^ (*model)) & 1)) { // MPS
                lbac->bitcounter += s_flag;
                lbac->range = rMPS;
                *model = tbl_plps[*model];
            } else {
                rLPS = (lbac->range << s_flag) - rMPS;
                int shift = get_shift(rLPS);
                lbac->range = rLPS << shift;
                lbac->bitcounter += shift + s_flag;
                *model = tbl_plps_ext[*model];
            }
        }
    } else {
        for (int bin = num_bin - 1; bin >= 0; bin--) {
            lbac_encode_bin((value >> bin) & 1, lbac, model++, bs);
        }
    }
}

static void lbac_encode_bins_ep_msb(u32 value, int num_bin, lbac_t *lbac, bs_t *bs)
{
    if (bs == NULL) {
        lbac->bitcounter += num_bin;
    } else {
        for (int bin = num_bin - 1; bin >= 0; bin--) {
            lbac->code <<= 1;
            if ((value >> bin) & 1) {
                lbac->code += lbac->range;
            }
            if (--(lbac->left_bits) < 12) {
                carry_propagate(lbac, bs);
            }
        }
    }
}

void lbac_enc_affine_flag(lbac_t *lbac, bs_t *bs, core_t *core, int flag)
{
    if (core->cu_width >= AFF_SIZE && core->cu_height >= AFF_SIZE && core->info->sqh.affine_enable) {
        lbac_encode_bin(flag, lbac, lbac->h.affine_flag, bs);
    }
}

void lbac_enc_affine_mrg_idx(lbac_t *lbac, bs_t *bs, s16 affine_mrg_idx)
{
    lbac_write_truncate_unary_sym(affine_mrg_idx, LBAC_CTX_AFFINE_MRG, AFF_MAX_NUM_MRG, lbac, lbac->h.affine_mrg_idx, bs);
}

void lbac_enc_smvd_flag(lbac_t *lbac, bs_t *bs, int flag)
{
    lbac_encode_bin(flag, lbac, lbac->h.smvd_flag, bs);
}

void lbac_enc_part_size(lbac_t *lbac, bs_t *bs, core_t *core, int part_size, int cu_w, int cu_h, int pred_mode)
{
    int allow_dt = com_dt_allow(cu_w, cu_h, pred_mode, core->info->sqh.max_dt_size);

    if (!allow_dt || !core->info->sqh.dt_enable && pred_mode == MODE_INTRA) {
        return;
    }
    if (part_size == SIZE_2Nx2N) {
        lbac_encode_bin(0, lbac, lbac->h.part_size + 0, bs);
    } else {
        int hori_allow = (allow_dt >> 0) & 0x01;
        int vert_allow = (allow_dt >> 1) & 0x01;
        int dir = part_size == SIZE_2NxhN || part_size == SIZE_2NxnD || part_size == SIZE_2NxnU;

        lbac_encode_bin(1, lbac, lbac->h.part_size + 0, bs);

        if (hori_allow && vert_allow) {
            lbac_encode_bin(dir, lbac, lbac->h.part_size + 1, bs);
        }
        if (dir) { //hori
            if (part_size == SIZE_2NxhN) {
                lbac_encode_bin(1, lbac, lbac->h.part_size + 2, bs);
            } else {
                lbac_encode_bin(0, lbac, lbac->h.part_size + 2, bs);
                lbac_encode_bin(part_size == SIZE_2NxnD, lbac, lbac->h.part_size + 3, bs);
            }
        } else { //vert
            if (part_size == SIZE_hNx2N) {
                lbac_encode_bin(1, lbac, lbac->h.part_size + 4, bs);
            } else {
                lbac_encode_bin(0, lbac, lbac->h.part_size + 4, bs);
                lbac_encode_bin(part_size == SIZE_nRx2N, lbac, lbac->h.part_size + 5, bs);
            }
        }
    }
}

void lbac_enc_split_flag(lbac_t *lbac, bs_t *bs, core_t *core, int cu_width, int cu_height, int x, int y,  int flag)
{
    com_map_t *map = core->map;
    int h = 0;
    int i_scu = core->info->i_scu;
    int scup = PEL2SCU(y) * i_scu + PEL2SCU(x);

    if (y > 0 && map->map_scu[scup - i_scu].coded) {
        h += (1 << MCU_GET_LOGW(map->map_pos[scup - i_scu])) < cu_width;
    }
    if (x > 0 && map->map_scu[scup - 1].coded) {
        h += (1 << MCU_GET_LOGH(map->map_pos[scup - 1])) < cu_height;
    }
    if (core->pichdr->slice_type == SLICE_I && cu_width == 128 && cu_height == 128) {
        h = 3;
    }
    lbac_encode_bin(flag, lbac, lbac->h.split_flag + h, bs);
}

void lbac_enc_cons_pred_mode(lbac_t *lbac, bs_t *bs, u8 cons_pred_mode_child)
{
    assert(cons_pred_mode_child == ONLY_INTER || cons_pred_mode_child == ONLY_INTRA);
    lbac_encode_bin(cons_pred_mode_child == ONLY_INTRA, lbac, lbac->h.cons_mode, bs);
}

void lbac_enc_skip_flag(lbac_t *lbac, bs_t *bs, core_t *core, int flag)
{
    com_scu_t *map_scu = core->map->map_scu;
    int scup = core->cu_scup_in_pic;
    int i_scu = core->info->i_scu;
    int ctx_inc = 0;

    if (core->cu_scu_y > 0 && map_scu[scup - i_scu].coded) {
        ctx_inc += map_scu[scup - i_scu].skip;
    }
    if (core->cu_scu_x > 0 && map_scu[scup - 1].coded) {
        ctx_inc += map_scu[scup - 1].skip;
    }
    if (core->cu_width_log2 + core->cu_height_log2 < 6) {
        ctx_inc = 3;
    }
    lbac_encode_bin(flag, lbac, lbac->h.skip_flag + ctx_inc, bs);
}

void lbac_enc_umve_flag(lbac_t *lbac, bs_t *bs, int flag)
{
    lbac_encode_bin(flag, lbac, &lbac->h.umve_flag, bs);
}

void lbac_enc_umve_idx(lbac_t *lbac, bs_t *bs, int umve_idx)
{
    int idx;
    int base_idx = umve_idx / UMVE_MAX_REFINE_NUM;
    int ref_step = (umve_idx - (base_idx * UMVE_MAX_REFINE_NUM)) / 4;
    int direction = umve_idx - base_idx * UMVE_MAX_REFINE_NUM - ref_step * 4;

    lbac_encode_bin(!base_idx, lbac, lbac->h.umve_base_idx, bs);

    if (ref_step == 0) {
        lbac_encode_bin(1, lbac, lbac->h.umve_step_idx, bs);
    } else {
        lbac_encode_bin(0, lbac, lbac->h.umve_step_idx, bs);
        for (idx = 1; idx < UMVE_REFINE_STEP - 1; idx++) {
            lbac_encode_bin_ep(ref_step == idx ? 1 : 0, lbac, bs);

            if (ref_step == idx) {
                break;
            }
        }
    }
    lbac_encode_bins_msb(direction, 2, lbac, lbac->h.umve_dir_idx, bs);
}

void lbac_enc_skip_idx(lbac_t *lbac, bs_t *bs, com_pic_header_t *pichdr, int skip_idx, int num_hmvp_cands)
{
    int ctx_idx = 0;
    int max_skip_num = (pichdr->slice_type == SLICE_P ? 2 : TRADITIONAL_SKIP_NUM) + num_hmvp_cands;

    if (pichdr->slice_type == SLICE_P && skip_idx > 0) { // for P slice, change 3, 4, ..., 13 to 1, 2, ..., 11
        skip_idx -= 2;
    }
    lbac_write_truncate_unary_sym(skip_idx, LBAC_CTX_SKIP_IDX, max_skip_num, lbac, lbac->h.skip_idx_ctx, bs);
}

void lbac_enc_direct_flag(lbac_t *lbac, bs_t *bs, core_t *core, int direct_flag)
{
    int ctx_inc = 0;
    if ((core->cu_width_log2 + core->cu_height_log2 < 6) || core->cu_width_log2 > 6 || core->cu_height_log2 > 6) {
        ctx_inc = 1;
    }
    lbac_encode_bin(direct_flag, lbac, lbac->h.direct_flag + ctx_inc, bs);
}

void lbac_enc_slice_end_flag(lbac_t *lbac, bs_t *bs, int flag)
{
    lbac_encode_bin_trm(flag, lbac, bs);
}

static int lbac_enc_run(u32 sym, lbac_t *lbac, lbac_ctx_model_t *model, bs_t *bs)
{
    int exp_golomb_order = 0;

    if (sym < 16) {
        lbac_write_truncate_unary_sym(sym, 2, 17, lbac, model, bs);
    } else {
        sym -= 16;
        lbac_write_truncate_unary_sym(16, 2, 17, lbac, model, bs);

        while ((int)sym >= (1 << exp_golomb_order)) {
            sym = sym - (1 << exp_golomb_order);
            exp_golomb_order++;
        }
        lbac_write_unary_sym_ep(exp_golomb_order, lbac, bs);
        lbac_encode_bins_ep_msb(sym, exp_golomb_order, lbac, bs);
    }
    return COM_OK;
}

void lbac_encode_bin_for_rdoq(u32 bin, lbac_ctx_model_t *model)
{
    if (bin != ((*model) & 1)) {
        *model = tbl_plps_ext[*model];
    } else {
        *model = tbl_plps[*model];
    }
}

static void lbac_enc_run_for_rdoq(u32 sym, u32 num_ctx, lbac_ctx_model_t *model)
{
    u32 ctx_idx = 0;

    do {
        lbac_encode_bin_for_rdoq(sym ? 0 : 1, model + COM_MIN(ctx_idx, num_ctx - 1));
        ctx_idx++;
    } while (sym--);
}

static int lbac_enc_level(u32 sym, lbac_t *lbac, lbac_ctx_model_t *model, bs_t *bs)
{
    int exp_golomb_order = 0;

    if (sym < 8) {
        lbac_write_truncate_unary_sym(sym, 2, 9, lbac, model, bs);
    } else {
        sym -= 8;
        lbac_write_truncate_unary_sym(8, 2, 9, lbac, model, bs);

        while ((int)sym >= (1 << exp_golomb_order)) {
            sym = sym - (1 << exp_golomb_order);
            exp_golomb_order++;
        }
        lbac_write_unary_sym_ep(exp_golomb_order, lbac, bs);
        lbac_encode_bins_ep_msb(sym, exp_golomb_order, lbac, bs);
    }
    return COM_OK;
}

void lbac_enc_run_length_cc(lbac_t *lbac, bs_t *bs, s16 *coef, int log2_w, int log2_h, int num_sig, int ch_type)
{
    com_lbac_all_ctx_t *lbac_ctx = &lbac->h;
    const u16 *scanp = com_tbl_scan[log2_w - 1][log2_h - 1];
    lbac_ctx_model_t *ctx_last1    = lbac_ctx->last1    + (ch_type == Y_C ? 0 : LBAC_CTX_LAST1);
    lbac_ctx_model_t *ctx_last2    = lbac_ctx->last2    + (ch_type == Y_C ? 0 : LBAC_CTX_LAST2);
    lbac_ctx_model_t *ctx_run      = lbac_ctx->run      + (ch_type == Y_C ? 0 : 12);
    lbac_ctx_model_t *ctx_run_rdoq = lbac_ctx->run_rdoq + (ch_type == Y_C ? 0 : 12);
    lbac_ctx_model_t *ctx_level    = lbac_ctx->level    + (ch_type == Y_C ? 0 : 12);
    u32 num_coeff = 1 << (log2_w + log2_h);
    u32 run = 0;
    u32 prev_level = 6;

    for (u32 scan_pos = 0; scan_pos < num_coeff; scan_pos++) {
        s16 coef_cur = coef[scanp[scan_pos]];

        if (coef_cur) {
            u32 level = COM_ABS16(coef_cur);
            s32 t0 = (COM_MIN(prev_level - 1, 5)) << 1;

            /* Run coding */
            lbac_enc_run(run, lbac, &ctx_run[t0], bs);
            lbac_enc_run_for_rdoq(run, 2, &ctx_run_rdoq[t0]);

            /* Level coding */
            lbac_enc_level(level - 1, lbac, &ctx_level[t0], bs);

            /* Sign coding */
            lbac_encode_bin_ep(coef_cur <= 0, lbac, bs);
            if (scan_pos == num_coeff - 1) {
                assert(num_sig == 1);
                break;
            }
            run = 0;
            num_sig--;
            /* Last flag coding */
            int last_flag = (num_sig == 0) ? 1 : 0;
            lbac_encode_binW(num_sig == 0, lbac, &ctx_last1[t0 >> 1], &ctx_last2[uavs3e_get_log2(scan_pos + 1)], bs);
            prev_level = level;

            if (last_flag) {
                break;
            }
        } else {
            run++;
        }
    }
}

void lbac_enc_run_length_cc_rdo(lbac_t *lbac, s16 *coef, int log2_w, int log2_h, int num_sig, int ch_type)
{
    com_lbac_all_ctx_t *lbac_ctx = &lbac->h;
    lbac_ctx_model_t *ctx_last1    = lbac_ctx->last1    + (ch_type == Y_C ? 0 : LBAC_CTX_LAST1);
    lbac_ctx_model_t *ctx_last2    = lbac_ctx->last2    + (ch_type == Y_C ? 0 : LBAC_CTX_LAST2);
    lbac_ctx_model_t *ctx_run      = lbac_ctx->run      + (ch_type == Y_C ? 0 : 12);
    lbac_ctx_model_t *ctx_run_rdoq = lbac_ctx->run_rdoq + (ch_type == Y_C ? 0 : 12);
    lbac_ctx_model_t *ctx_level    = lbac_ctx->level    + (ch_type == Y_C ? 0 : 12);
    u32 num_coeff = 1 << (log2_w + log2_h);
    u32 run = 0;
    u32 t0 = 10;
    int bitcounter = 0;
    int range = lbac->range;
    const u16 *scanp = com_tbl_scan[log2_w - 1][log2_h - 1];
    tab_s16 *switch_tab_plps[2] = { tbl_plps_ext, tbl_plps };
    u32 scan_pos = 0;
    s16 coef_cur;
    int last_nz_pos = -1;

    do {
        while (!(coef_cur = coef[scanp[scan_pos]])) {
            scan_pos++;
        }
        run = scan_pos - last_nz_pos - 1;
        last_nz_pos = scan_pos;

        /* Run coding */
        int sym = COM_MIN(run, 16);
        lbac_ctx_model_t *model = ctx_run + t0;

        { /* first bin of Run */
            u32 rMPS = range - (((*model) & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1));
            int s_flag = rMPS < QUAR_HALF_PROB;
            rMPS |= 0x100;

            if (!sym == ((*model) & 1)) { // MPS
                bitcounter += s_flag;
                range = rMPS;
                *model = tbl_plps[*model];
            } else {
                u32 rLPS = (range << s_flag) - rMPS;
                int shift = get_shift(rLPS);
                range = rLPS << shift;
                bitcounter += shift + s_flag;
                *model = tbl_plps_ext[*model];
            }
        }

        u32 ctx_idx = 0;

        if (sym--) { 
            lbac_ctx_model_t m = model[1];
            ctx_idx++;

            if ((m & 1) == 0 && sym > 0) { // MPS == '0'
                ctx_idx += sym;

                do { // MPS
                    u32 rMPS = range - ((m & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1));
                    range = rMPS | 0x100;
                    bitcounter += rMPS < QUAR_HALF_PROB;
                    m = tbl_plps[m];
                } while (sym-- > 1);

                if (ctx_idx < 16) { // sym == 0
                    u32 rMPS = range - ((m & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1));
                    int s_flag = rMPS < QUAR_HALF_PROB;
                    u32 rLPS = (range << s_flag) - (rMPS | 0x100);
                    int shift = get_shift(rLPS);
                    range = rLPS << shift;
                    bitcounter += shift + s_flag;
                    m = tbl_plps_ext[m];
                }
            } else {
                do {
                    u32 rMPS = range - ((m & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1));
                    int s_flag = rMPS < QUAR_HALF_PROB;
                    rMPS |= 0x100;

                    if (!sym == (m & 1)) { // MPS
                        bitcounter += s_flag;
                        range = rMPS;
                        m = tbl_plps[m];
                    } else {
                        u32 rLPS = (range << s_flag) - rMPS;
                        int shift = get_shift(rLPS);
                        range = rLPS << shift;
                        bitcounter += shift + s_flag;
                        m = tbl_plps_ext[m];
                    }
                } while (++ctx_idx < 16 && sym--);
            }
            model[1] = m;
        }

        if (run >= 16) {
            int exp_golomb_order = 1;
            sym = run - 17;

            while ((int)sym >= 0) {
                sym = sym - (1 << exp_golomb_order);
                exp_golomb_order++;
            }
            bitcounter += (exp_golomb_order << 1) - 1;
        }

        sym = run;
        model = ctx_run_rdoq + t0;
        *model = switch_tab_plps[!sym == ((*model) & 1)][*model];

        if (sym--) {
            model++;
            do {
                *model = switch_tab_plps[!sym == ((*model) & 1)][*model];
            } while (sym--);
        }

        /* Level coding */
        u32 level = COM_ABS16(coef_cur);
        model = &ctx_level[t0];

        sym = COM_MIN(level - 1, 8);

        { /* first bin of Level */
            u32 rLPS = ((*model) & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1);
            u32 rMPS = range - rLPS;
            int s_flag = rMPS < QUAR_HALF_PROB;
            rMPS |= 0x100;

            if (!sym == ((*model) & 1)) { // MPS
                bitcounter += s_flag;
                range = rMPS;
                *model = tbl_plps[*model];
            }
            else {
                rLPS = (range << s_flag) - rMPS;
                int shift = get_shift(rLPS);
                range = rLPS << shift;
                bitcounter += shift + s_flag;
                *model = tbl_plps_ext[*model];
            }
        }

        ctx_idx = 0;

        if (sym--) {
            lbac_ctx_model_t m = model[1];
            ctx_idx++;

            if ((m & 1) == 0 && sym) { // MPS == '0'
                ctx_idx += sym;

                do { // MPS
                    u32 rMPS = range - ((m & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1));
                    range = rMPS | 0x100;
                    bitcounter += rMPS < QUAR_HALF_PROB;
                    m = tbl_plps[m];
                } while (sym-- > 1);

                if (ctx_idx < 8) { // sym == 0
                    u32 rMPS = range - ((m & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1));
                    int s_flag = rMPS < QUAR_HALF_PROB;
                    u32 rLPS = (range << s_flag) - (rMPS | 0x100);
                    int shift = get_shift(rLPS);
                    range = rLPS << shift;
                    bitcounter += shift + s_flag;
                    m = tbl_plps_ext[m];
                }
            } else {
                do {
                    u32 rMPS = range - ((m & PROB_MASK) >> (LG_PMPS_SHIFTNO + 1));
                    int s_flag = rMPS < QUAR_HALF_PROB;
                    rMPS |= 0x100;

                    if (!sym == (m & 1)) { // MPS
                        bitcounter += s_flag;
                        range = rMPS;
                        m = tbl_plps[m];
                    } else {
                        u32 rLPS = (range << s_flag) - rMPS;
                        int shift = get_shift(rLPS);
                        range = rLPS << shift;
                        bitcounter += shift + s_flag;
                        m = tbl_plps_ext[m];
                    }
                } while (++ctx_idx < 8 && sym--);
            }

            model[1] = m;
        }

        if (level >= 9) {
            int exp_golomb_order = 1;
            sym = level - 10;

            while ((int)sym >= 0) {
                sym = sym - (1 << exp_golomb_order);
                exp_golomb_order++;
            }
            bitcounter += (exp_golomb_order << 1) - 1;
        }

        /* Sign coding */
        bitcounter++;
        
        if (scan_pos == num_coeff - 1) {
            assert(num_sig == 1);
            break;
        }
        run = 0;
        num_sig--;

        /* Last flag coding */
        lbac_ctx_model_t *model1 = &ctx_last1[t0 >> 1];
        lbac_ctx_model_t *model2 = &ctx_last2[uavs3e_get_log2(scan_pos + 1)];
        u16 prob_lps;
        u16 prob_lps1 = ((*model1) & PROB_MASK) >> 1;
        u16 prob_lps2 = ((*model2) & PROB_MASK) >> 1;
        u16 cmps1 = (*model1) & 1;
        u16 cmps2 = (*model2) & 1;
        u16 cmps;

        t0 = (COM_MIN(level - 1, 5)) << 1;

        if (cmps1 == cmps2) {
            cmps = cmps1;
            prob_lps = (prob_lps1 + prob_lps2) >> 1;
        } else {
            if (prob_lps1 < prob_lps2) {
                cmps = cmps1;
                prob_lps = (256 << LG_PMPS_SHIFTNO) - 1 - ((prob_lps2 - prob_lps1) >> 1);
            } else {
                cmps = cmps2;
                prob_lps = (256 << LG_PMPS_SHIFTNO) - 1 - ((prob_lps1 - prob_lps2) >> 1);
            }
        }

        u32 rLPS = prob_lps >> LG_PMPS_SHIFTNO;
        u32 rMPS = range - rLPS;
        int s_flag = rMPS < QUAR_HALF_PROB;
        int last_flag = !num_sig;

        rMPS |= 0x100;

        if (last_flag == cmps) { // MPS
            bitcounter += s_flag;
            range = rMPS;
        } else {
            rLPS = (range << s_flag) - rMPS;
            int shift = get_shift(rLPS);
            range = rLPS << shift;
            bitcounter += shift + s_flag;
        }
        *model1 = switch_tab_plps[last_flag == cmps1][*model1];
        *model2 = switch_tab_plps[last_flag == cmps2][*model2];

        scan_pos++;

    } while (num_sig);

    lbac->range = range;
    lbac->bitcounter += bitcounter;
}

void lbac_enc_xcoef(lbac_t *lbac, bs_t *bs, s16 *coef, int log2_w, int log2_h, int num_sig, int ch_type)
{
    if ((log2_w > MAX_TR_LOG2) || (log2_h > MAX_TR_LOG2)) {
        assert(0);
    } else {
        if (bs == NULL) {
            lbac_enc_run_length_cc_rdo(lbac, coef, log2_w, log2_h, num_sig, (ch_type == Y_C ? 0 : 1));
        } else {
            lbac_enc_run_length_cc(lbac, bs, coef, log2_w, log2_h, num_sig, (ch_type == Y_C ? 0 : 1));
        }
    }
}

int lbac_enc_cbf_uv(lbac_t *lbac, bs_t *bs, int num_nz[MAX_NUM_TB][N_C])
{
    com_lbac_all_ctx_t *lbac_ctx = &lbac->h;
    assert(num_nz[TBUV0][Y_C] == 0);

    lbac_encode_bin(!!num_nz[TBUV0][U_C], lbac, lbac_ctx->cbf + 1, bs);
    lbac_encode_bin(!!num_nz[TBUV0][V_C], lbac, lbac_ctx->cbf + 2, bs);

    return COM_OK;
}

int lbac_enc_cbf(lbac_t *lbac, bs_t *bs, core_t *core, int tb_avaliable, int pb_part_size, int tb_part_size, int num_nz[MAX_NUM_TB][N_C], u8 pred_mode, s8 ipm[MAX_NUM_PB][2], u8 tree_status)
{
    com_lbac_all_ctx_t *lbac_ctx = &lbac->h;
    int ctp_zero_flag = !is_cu_nz(num_nz);

    /* code allcbf */
    if (pred_mode != MODE_INTRA) {
        if (pred_mode == MODE_DIR) {
            assert(ctp_zero_flag == 0);
        } else {
            if (tree_status == TREE_LC) {
                if (core->cu_width_log2 > 6 || core->cu_height_log2 > 6) {
                    lbac_encode_bin(1, lbac, lbac_ctx->ctp_zero_flag + 1, bs);
                    assert(ctp_zero_flag == 1);
                } else {
                    lbac_encode_bin(ctp_zero_flag, lbac, lbac_ctx->ctp_zero_flag, bs);
                }
                if (ctp_zero_flag) {
                    for (int i = 0; i < MAX_NUM_TB; i++) {
                        assert(num_nz[i][Y_C] == 0 && num_nz[i][U_C] == 0 && num_nz[i][V_C] == 0);
                    }
                    assert(tb_part_size == SIZE_2Nx2N);
                    return COM_OK;
                }
            }
        }
        if (tb_avaliable) {
            lbac_encode_bin(tb_part_size != SIZE_2Nx2N, lbac, lbac_ctx->tb_split, bs);
        } else {
            assert(tb_part_size == SIZE_2Nx2N);
        }
        if (tree_status == TREE_LC) {
            lbac_encode_bin(!!num_nz[TBUV0][U_C], lbac, lbac_ctx->cbf + 1, bs);
            lbac_encode_bin(!!num_nz[TBUV0][V_C], lbac, lbac_ctx->cbf + 2, bs);
        } else {
            assert(tree_status == TREE_L);
        }
        if (num_nz[TBUV0][U_C] + num_nz[TBUV0][V_C] == 0 && tb_part_size == SIZE_2Nx2N && tree_status == TREE_LC) {
            assert(num_nz[TB0][Y_C] > 0);
        } else {
            int i, part_num = get_part_num(tb_part_size);
            for (i = 0; i < part_num; i++) {
                lbac_encode_bin(!!num_nz[i][Y_C], lbac, lbac_ctx->cbf, bs);
            }
        }
    } else {
        if (!(ipm[PB0][0] == IPD_IPCM)) {
            int i, part_num = get_part_num(tb_part_size);
            assert(tb_part_size == get_tb_part_size_by_pb(pb_part_size, pred_mode));

            for (i = 0; i < part_num; i++) {
                lbac_encode_bin(!!num_nz[i][Y_C], lbac, lbac_ctx->cbf, bs);
            }
        }
        if (tree_status == TREE_LC) {
            if (!(ipm[PB0][0] == IPD_IPCM && ipm[PB0][1] == IPD_DM_C)) {
                lbac_encode_bin(!!num_nz[TBUV0][U_C], lbac, lbac_ctx->cbf + 1, bs);
                lbac_encode_bin(!!num_nz[TBUV0][V_C], lbac, lbac_ctx->cbf + 2, bs);
            }
        } else {
            assert(tree_status == TREE_L);
        }
    }
    return COM_OK;
}

int lbac_enc_coef(lbac_t *lbac, bs_t *bs, core_t *core, s16 coef[N_C][MAX_CU_DIM], int cu_width_log2, int cu_height_log2, u8 pred_mode, com_mode_t *mi, u8 tree_status)
{
    part_size_t tb_part_size = mi->tb_part;
    part_size_t pb_part_size = mi->pb_part;
    int i, j;
    int tb_avaliable = is_tb_avaliable(core->info, cu_width_log2, cu_height_log2, pb_part_size, pred_mode);
    int start_comp, num_comp;
    start_comp = (tree_status == TREE_L || tree_status == TREE_LC) ? Y_C : U_C;
    num_comp = (tree_status == TREE_LC) ? 3 : (tree_status == TREE_L ? 1 : 2);

    if (tree_status != TREE_C) {
        lbac_enc_cbf(lbac, bs, core, tb_avaliable, pb_part_size, tb_part_size, mi->num_nz, pred_mode, mi->ipm, tree_status);
    } else if (!(pred_mode == MODE_INTRA && mi->ipm[0][0] == IPD_IPCM && mi->ipm[0][1] == IPD_DM_C)) {
        lbac_enc_cbf_uv(lbac, bs, mi->num_nz);
    }

    for (i = start_comp; i < start_comp + num_comp; i++) {
        int log2_tb_w, log2_tb_h, tb_size, part_num;
        int plane_width_log2  = cu_width_log2  - (i != Y_C);
        int plane_height_log2 = cu_height_log2 - (i != Y_C);

        if (pred_mode == MODE_INTRA && ((i == Y_C && mi->ipm[0][0] == IPD_IPCM) || (i > Y_C && mi->ipm[0][0] == IPD_IPCM && mi->ipm[0][1] == IPD_DM_C))) {
            if (i == start_comp) {
                lbac_encode_bin_trm(1, lbac, bs);
                lbac_finish(lbac, bs);
            }
            int tb_w = plane_width_log2 > 5 ? 32 : (1 << plane_width_log2);
            int tb_h = plane_height_log2 > 5 ? 32 : (1 << plane_height_log2);
            int num_tb_w = plane_width_log2 > 5 ? 1 << (plane_width_log2 - 5) : 1;
            int num_tb_h = plane_height_log2 > 5 ? 1 << (plane_height_log2 - 5) : 1;
            for (int h = 0; h < num_tb_h; h++) {
                for (int w = 0; w < num_tb_w; w++) {
                    s16 *coef_tb = coef[i] + (1 << plane_width_log2) * h * tb_h + w * tb_w;
                    lbac_enc_ipcm(lbac, bs, coef_tb, tb_w, tb_h, 1 << plane_width_log2, core->info->bit_depth_input, i);
                }
            }
            if ((i == Y_C && (tree_status == TREE_L || (tree_status == TREE_LC && mi->ipm[0][1] != IPD_DM_C))) || i == V_C) {
                /* byte align */
                while (!IS_BYTE_ALIGN(bs)) {
                    bs_write1(bs, 0);
                }
                lbac_reset(lbac);
            }
        } else {
            part_num = get_part_num(i == 0 ? tb_part_size : SIZE_2Nx2N);
            get_tb_width_height_log2(plane_width_log2, plane_height_log2, i == 0 ? tb_part_size : SIZE_2Nx2N, &log2_tb_w, &log2_tb_h);
            tb_size = 1 << (log2_tb_w + log2_tb_h);

            for (j = 0; j < part_num; j++) {
                if (mi->num_nz[j][i]) {
                    lbac_enc_xcoef(lbac, bs, coef[i] + j * tb_size, log2_tb_w, log2_tb_h, mi->num_nz[j][i], i);
                }
            }
        }
    }
    return COM_OK;
}

int lbac_enc_pred_mode(lbac_t *lbac, bs_t *bs, core_t *core, u8 pred_mode)
{
    com_scu_t *map_scu = core->map->map_scu;
    int scup = core->cu_scup_in_pic;
    int i_scu = core->info->i_scu;
    int ctx_inc = COM_IS_INTRA_SCU(map_scu[scup - i_scu]) + COM_IS_INTRA_SCU(map_scu[scup - 1]);

    if (ctx_inc == 0) {
        int sample = (1 << core->cu_width_log2) * (1 << core->cu_height_log2);
        ctx_inc = (sample > 256) ? 0 : (sample > 64 ? 3 : 4);
    }
    if (core->cu_width_log2 > 6 || core->cu_height_log2 > 6) {
        ctx_inc = 5;
    }
    lbac_encode_bin(pred_mode == MODE_INTRA, lbac, lbac->h.pred_mode + ctx_inc, bs);
    return COM_OK;
}

int lbac_enc_intra_dir(lbac_t *lbac, bs_t *bs, u8 ipm, u8 mpm[2])
{
    int ipm_code = (ipm == mpm[0]) ? -2 : ((mpm[1] == ipm) ? -1 : ((ipm < mpm[0]) ? ipm : ((ipm < mpm[1]) ? (ipm - 1) : (ipm - 2))));

    if (ipm_code < 0) {
        lbac_encode_bin(1, lbac, lbac->h.intra_dir, bs);
        lbac_encode_bin(ipm_code + 2, lbac, lbac->h.intra_dir + 6, bs);
    } else {
        lbac_encode_bin(0, lbac, lbac->h.intra_dir, bs);
        lbac_encode_bins_msb(ipm_code, 5, lbac, lbac->h.intra_dir + 1, bs);
    }
    return COM_OK;
}

int lbac_enc_intra_dir_c(lbac_t *lbac, bs_t *bs, u8 ipm, u8 ipm_l, u8 tscpm_enable)
{
    u8 chk_bypass;
    COM_IPRED_CONV_L2C_CHK(ipm_l, chk_bypass);
    lbac_encode_bin(!ipm, lbac, lbac->h.intra_dir + 7, bs);

    if (ipm) {
        if (tscpm_enable) {
            if (ipm == IPD_TSCPM_C) {
                lbac_encode_bin(1, lbac, lbac->h.intra_dir + 9, bs);
                return COM_OK;
            } else {
                lbac_encode_bin(0, lbac, lbac->h.intra_dir + 9, bs);
            }
        }
        u8 symbol = (chk_bypass && ipm > ipm_l) ? ipm - 2 : ipm - 1;
        lbac_write_truncate_unary_sym(symbol, 1, IPD_CHROMA_CNT - 1, lbac, lbac->h.intra_dir + 8, bs);
    }
    return COM_OK;
}

void lbac_enc_ipcm(lbac_t *lbac, bs_t *bs, s16 pcm[MAX_CU_DIM], int tb_width, int tb_height, int cu_width, int bit_depth, int ch_type)
{
    int i, j;
    for (i = 0; i < tb_height; i++) {
        for (j = 0; j < tb_width; j++) {
            if (bs == NULL) {
                bs_write_est(lbac, bit_depth);
            } else {
                bs_write(bs, pcm[i * cu_width + j], bit_depth);
            }
        }
    }
}

void lbac_enc_inter_dir(lbac_t *lbac, bs_t *bs, core_t *core, s8 refi[REFP_NUM], int part_size)
{
    if (REFI_IS_VALID(refi[REFP_0]) && REFI_IS_VALID(refi[REFP_1])) { /* PRED_BI */
        lbac_encode_bin(1, lbac, lbac->h.inter_dir, bs);
    } else {
        if (core->cu_width_log2 + core->cu_height_log2 < 6) {
            lbac_encode_bin(0, lbac, lbac->h.inter_dir + 2, bs);
        } else {
            lbac_encode_bin(0, lbac, lbac->h.inter_dir, bs);
        }
        lbac_encode_bin(refi[REFP_0] == REFI_INVALID, lbac, lbac->h.inter_dir + 1, bs);
    }
    return;
}

int lbac_enc_refi(lbac_t *lbac, bs_t *bs, int num_refp, int refi)
{
    if (num_refp > 1) {
        lbac_write_truncate_unary_sym(refi, 3, num_refp, lbac, lbac->h.refi, bs);
    }
    return COM_OK;
}

int lbac_enc_mvr_idx(lbac_t *lbac, bs_t *bs, u8 mvr_idx, BOOL is_affine_mode)
{
    if (is_affine_mode) {
        lbac_write_truncate_unary_sym(mvr_idx, LBAC_CTX_AFFINE_MVR_IDX, MAX_NUM_AFFINE_MVR, lbac, lbac->h.affine_mvr_idx, bs);
    } else {
        lbac_write_truncate_unary_sym(mvr_idx, LBAC_CTX_MVR_IDX, MAX_NUM_MVR, lbac, lbac->h.mvr_idx, bs);
    }
    return COM_OK;
}

void lbac_enc_mvr_flag_extend(lbac_t *lbac, bs_t *bs, u8 hmvp_flag)
{
    lbac_encode_bin(hmvp_flag, lbac, lbac->h.hmvp_flag, bs);
}

int lbac_enc_ipf_flag(lbac_t *lbac, bs_t *bs, u8 ipf_flag)
{
    lbac_encode_bin(ipf_flag, lbac, lbac->h.ipf_flag, bs);
    return COM_OK;
}

static int lbac_enc_abs_mvd(u32 sym, lbac_t *lbac, lbac_ctx_model_t *model, bs_t *bs)
{
    int exp_golomb_order = 0;

    if (sym < 3) { // 0, 1, 2
        if (sym == 0) {
            lbac_encode_bin(0, lbac, model, bs);
        } else if (sym == 1) {
            lbac_encode_bin(1, lbac, model, bs);
            lbac_encode_bin(0, lbac, model + 1, bs);
        } else if (sym == 2) {
            lbac_encode_bin(1, lbac, model, bs);
            lbac_encode_bin(1, lbac, model + 1, bs);
            lbac_encode_bin(0, lbac, model + 2, bs);
        }
    } else {
        int offset;

        sym -= 3;
        offset = sym & 1;
        lbac_encode_bin(1, lbac, model, bs);
        lbac_encode_bin(1, lbac, model + 1, bs);
        lbac_encode_bin(1, lbac, model + 2, bs);

        lbac_encode_bin_ep(offset, lbac, bs);
        sym = (sym - offset) >> 1;

        while ((int)sym >= (1 << exp_golomb_order)) {
            sym = sym - (1 << exp_golomb_order);
            exp_golomb_order++;
        }
        lbac_write_unary_sym_ep(exp_golomb_order, lbac, bs);
        lbac_encode_bins_ep_msb(sym, exp_golomb_order, lbac, bs);
    }

    return COM_OK;
}

int lbac_enc_mvd(lbac_t *lbac, bs_t *bs, s16 mvd[MV_D])
{
    com_lbac_all_ctx_t *lbac_ctx = &lbac->h;

    if (mvd[MV_X] == 0) {
        lbac_enc_abs_mvd(0, lbac, lbac_ctx->mvd[0], bs);
    } else if (mvd[MV_X] < 0) {
        lbac_enc_abs_mvd(-mvd[MV_X], lbac, lbac_ctx->mvd[0], bs);
        lbac_encode_bin_ep(1, lbac, bs);
    } else {
        lbac_enc_abs_mvd(mvd[MV_X], lbac, lbac_ctx->mvd[0], bs);
        lbac_encode_bin_ep(0, lbac, bs);
    }
    if (mvd[MV_Y] == 0) {
        lbac_enc_abs_mvd(0, lbac, lbac_ctx->mvd[1], bs);
    } else if (mvd[MV_Y] < 0) {
        lbac_enc_abs_mvd(-mvd[MV_Y], lbac, lbac_ctx->mvd[1], bs);
        lbac_encode_bin_ep(1, lbac, bs);
    } else {
        lbac_enc_abs_mvd(mvd[MV_Y], lbac, lbac_ctx->mvd[1], bs);
        lbac_encode_bin_ep(0, lbac, bs);
    }
    return COM_OK;
}

static int cu_init(core_t *core, enc_cu_t *cu_data, int x, int y, int cup, int cu_width, int cu_height)
{
    com_mode_t *cur_info = &core->mod_info_curr;

    core->cu_width        = cu_width;
    core->cu_height       = cu_height;
    core->cu_width_log2   = CONV_LOG2(cu_width);
    core->cu_height_log2  = CONV_LOG2(cu_height);
    core->cu_scu_x        = PEL2SCU(x);
    core->cu_scu_y        = PEL2SCU(y);
    core->cu_scup_in_pic  = (core->cu_scu_y * core->info->i_scu) + core->cu_scu_x;
    core->skip_flag       = 0;

    cur_info->affine_flag   = cu_data->affine_flag[cup];
    cur_info->smvd_flag     = cu_data->smvd_flag[cup];
    cur_info->pb_part       = cu_data->pb_part[cup];
    cur_info->tb_part       = cu_data->tb_part[cup];

    cu_nz_cln(cur_info->num_nz);

    if (core->tree_status != TREE_C) {
        if (cu_data->pred_mode[cup] == MODE_SKIP) {
            core->skip_flag = 1;
        }
    }
    return COM_OK;
}

static void coef_rect_to_series(com_info_t *info, s16 *coef_src[N_C], int x, int y, int cu_width, int cu_height, s16 coef_dst[N_C][MAX_CU_DIM])
{
    int i, j, sidx, didx;
    sidx = (x & (info->max_cuwh - 1)) + ((y & (info->max_cuwh - 1)) << info->log2_max_cuwh);
    didx = 0;
    for (j = 0; j < cu_height; j++) {
        for (i = 0; i < cu_width; i++) {
            coef_dst[Y_C][didx++] = coef_src[Y_C][sidx + i];
        }
        sidx += info->max_cuwh;
    }
    x >>= 1;
    y >>= 1;
    cu_width >>= 1;
    cu_height >>= 1;
    sidx = (x & ((info->max_cuwh >> 1) - 1)) + ((y & ((info->max_cuwh >> 1) - 1)) << (info->log2_max_cuwh - 1));
    didx = 0;
    for (j = 0; j < cu_height; j++) {
        for (i = 0; i < cu_width; i++) {
            coef_dst[U_C][didx] = coef_src[U_C][sidx + i];
            coef_dst[V_C][didx] = coef_src[V_C][sidx + i];
            didx++;
        }
        sidx += (info->max_cuwh >> 1);
    }
}

int lbac_enc_split_mode(lbac_t *lbac, bs_t *bs, core_t *core, s8 split_mode, int cud, int cup, int cu_width, int cu_height, int lcu_s
                       , const int parent_split, int qt_depth, int bet_depth, int x, int y)
{
    if (cu_width == MIN_CU_SIZE && cu_height == MIN_CU_SIZE) {
        return COM_OK;
    }

    int ret = COM_OK;
    int h = 0;
    int split_allow[NUM_SPLIT_MODE];
    int boundary = 0, boundary_b = 0, boundary_r = 0;
    com_info_t *info = core->info;
    com_map_t *map = core->map;

    boundary = !(x + cu_width <= info->pic_width && y + cu_height <= info->pic_height);
    boundary_b = boundary && (y + cu_height > info->pic_height) && !(x + cu_width  > info->pic_width );
    boundary_r = boundary && (x + cu_width  > info->pic_width ) && !(y + cu_height > info->pic_height);

    com_check_split_mode(&info->sqh, split_allow, CONV_LOG2(cu_width), CONV_LOG2(cu_height), boundary, boundary_b, boundary_r, info->log2_max_cuwh, parent_split, qt_depth, bet_depth, core->pichdr->slice_type);
   
    int non_QT_split_mode_num = 0;
    for (int i = 1; i < SPLIT_QUAD; i++) {
        non_QT_split_mode_num += split_allow[i];
    }
    if (split_allow[SPLIT_QUAD] && !(non_QT_split_mode_num || split_allow[NO_SPLIT])) { //only QT is allowed
        assert(split_mode == SPLIT_QUAD);
        return ret;
    } else if (split_allow[SPLIT_QUAD]) {
        lbac_enc_split_flag(lbac, bs, core, cu_width, cu_height, x, y, split_mode == SPLIT_QUAD);
        if (split_mode == SPLIT_QUAD) {
            return ret;
        }
    }
    if (non_QT_split_mode_num) {
        int cu_width_log2  = CONV_LOG2(cu_width);
        int cu_height_log2 = CONV_LOG2(cu_height);
        int x_scu = x >> MIN_CU_LOG2;
        int y_scu = y >> MIN_CU_LOG2;
        int i_scu = info->i_scu;
        int scup = x_scu + y_scu * i_scu;

        if (y_scu > 0 && map->map_scu[scup - i_scu].coded) {
            h += (1 << MCU_GET_LOGW(map->map_pos[scup - i_scu])) < cu_width;
        }
        if (x_scu > 0 && map->map_scu[scup - 1].coded) {
            h += (1 << MCU_GET_LOGH(map->map_pos[scup - 1])) < cu_height;
        }

        int sample = cu_width * cu_height;
        int ctx_set = (sample > 1024) ? 0 : (sample > 256 ? 1 : 2);

        if (split_allow[NO_SPLIT]) {
            lbac_encode_bin(split_mode != NO_SPLIT, lbac, lbac->h.bt_split_flag + h + ctx_set * 3, bs);
        } else {
            assert(split_mode != NO_SPLIT);
        }
        if (split_mode != NO_SPLIT) {
            int HBT = split_allow[SPLIT_BI_HOR];
            int VBT = split_allow[SPLIT_BI_VER];
            int EnableBT = HBT || VBT;

            int HEQT = split_allow[SPLIT_EQT_HOR];
            int VEQT = split_allow[SPLIT_EQT_VER];
            int EnableEQT = HEQT || VEQT;

            u8 ctx_dir = cu_width_log2 == cu_height_log2 ? 0 : (cu_width_log2 > cu_height_log2 ? 1 : 2);

            u8 split_dir = (split_mode == SPLIT_BI_VER) || (split_mode == SPLIT_EQT_VER);
            u8 split_typ = (split_mode == SPLIT_EQT_HOR) || (split_mode == SPLIT_EQT_VER);

            if (EnableEQT && EnableBT) {
                lbac_encode_bin(split_typ, lbac, lbac->h.split_mode + h, bs);
            }
            if (split_typ == 0) {
                if (HBT && VBT) {
                    if (cu_width == 64 && cu_height == 128) {
                        ctx_dir = 3;
                        assert(split_dir == 0);
                    }
                    if (cu_width == 128 && cu_height == 64) {
                        ctx_dir = 4;
                        assert(split_dir == 1);
                    }
                    lbac_encode_bin(split_dir, lbac, lbac->h.split_dir + ctx_dir, bs);
                }
            }
            if (split_typ == 1) {
                if (HEQT && VEQT) {
                    lbac_encode_bin(split_dir, lbac, lbac->h.split_dir + ctx_dir, bs);
                }
            }
        }
    }
    return ret;
}

int lbac_enc_unit_chroma(lbac_t *lbac, bs_t *bs, core_t *core, enc_cu_t *cu_data, int x, int y, int cup, int cu_width, int cu_height)
{
    s16(*coef)[MAX_CU_DIM] = core->ctmp;
    com_mode_t *cur_info = &core->mod_info_curr;
    com_info_t *info = core->info;
    int scu_stride = PEL2SCU(info->max_cuwh);
    int luma_scu_x = PEL2SCU((x % info->max_cuwh) + cu_width ) - 1;
    int luma_scu_y = PEL2SCU((y % info->max_cuwh) + cu_height)  -1;
    int luma_cup = luma_scu_y * scu_stride + luma_scu_x;

    cu_init(core, cu_data, x, y, cup, cu_width, cu_height);

    if (cu_data->pred_mode[luma_cup] != MODE_INTRA) {
        cur_info->cu_mode = MODE_INTER;
        for (int lidx = 0; lidx < REFP_NUM; lidx++) {
            cur_info->refi[lidx] = cu_data->refi[luma_cup][lidx];
            cur_info->mv[lidx][MV_X] = cu_data->mv[luma_cup][lidx][MV_X];
            cur_info->mv[lidx][MV_Y] = cu_data->mv[luma_cup][lidx][MV_Y];
        }
    } else {
        cur_info->cu_mode = MODE_INTRA;
        cur_info->ipm[PB0][0] = cu_data->ipm_l[luma_cup];
        cur_info->ipm[PB0][1] = cu_data->ipm_c[cup];
        lbac_enc_intra_dir_c(lbac, bs, cu_data->ipm_c[cup], cu_data->ipm_l[luma_cup], info->sqh.tscpm_enable);
        assert(cu_data->ipm_c[cup] == cu_data->ipm_c[luma_cup]);
    }

    /* get coefficients and tq */
    coef_rect_to_series(info, cu_data->coef, x, y, cu_width, cu_height, coef);

    cur_info->num_nz[0][U_C] = cu_data->num_nz_coef[U_C][cup];
    cur_info->num_nz[0][V_C] = cu_data->num_nz_coef[V_C][cup];
    lbac_enc_coef(lbac, bs, core, coef, core->cu_width_log2, core->cu_height_log2, cur_info->cu_mode, cur_info, core->tree_status);
    return COM_OK;
}

int lbac_enc_unit(lbac_t *lbac, bs_t *bs, core_t *core, enc_cu_t *cu_data, int x, int y, int cup, int cu_width, int cu_height)
{
    s16(*coef)[MAX_CU_DIM] = core->ctmp;
    com_scu_t *map_scu;
    int refi0, refi1;
    int i, j, w, h;
    u32 *map_pos;
    int cu_cbf_flag;
    com_mode_t *cur_info = &core->mod_info_curr;
    com_map_t *map = core->map;
    com_info_t *info = core->info;
    int slice_type = core->slice_type;
    int scu_stride = PEL2SCU(info->max_cuwh);

    cu_init(core, cu_data, x, y, cup, cu_width, cu_height);

    if (!core->skip_flag) {
        /* get coefficients and tq */
        coef_rect_to_series(info, cu_data->coef, x, y, cu_width, cu_height, coef);

        int part_num = get_part_num(cur_info->tb_part);

        for (j = 0; j < part_num; j++) {
            int pos_x, pos_y;
            get_tb_start_pos(cu_width, cu_height, cur_info->tb_part, j, &pos_x, &pos_y);
            cur_info->num_nz[j][Y_C] = cu_data->num_nz_coef[Y_C][cup + PEL2SCU(pos_y) * scu_stride + PEL2SCU(pos_x)];
        }
        cur_info->num_nz[0][U_C] = cu_data->num_nz_coef[U_C][cup];
        cur_info->num_nz[0][V_C] = cu_data->num_nz_coef[V_C][cup];
    }
    /* entropy coding a CU */
    if (slice_type != SLICE_I) {
        if (core->cons_pred_mode == ONLY_INTRA) {
            assert(core->skip_flag == 0 && cu_data->pred_mode[cup] == MODE_INTRA);
        }
        if (core->cons_pred_mode != ONLY_INTRA) {
            lbac_enc_skip_flag(lbac, bs, core, core->skip_flag);
        }
        if (core->skip_flag) {
            assert(cu_data->pb_part[cup] == SIZE_2Nx2N);
            if (info->sqh.umve_enable) {
                lbac_enc_umve_flag(lbac, bs, cu_data->umve_flag[cup]);
            }
            if (cu_data->umve_flag[cup]) {
                lbac_enc_umve_idx(lbac, bs, cu_data->umve_idx[cup]);
            } else {
                lbac_enc_affine_flag(lbac, bs, core, cur_info->affine_flag != 0);
                if (cur_info->affine_flag) {
                    lbac_enc_affine_mrg_idx(lbac, bs, cu_data->skip_idx[cup]);
                } else {
                    lbac_enc_skip_idx(lbac, bs, core->pichdr, cu_data->skip_idx[cup], info->sqh.num_of_hmvp);
                }
            }
        } else {
            if (core->cons_pred_mode != ONLY_INTRA) {
                lbac_enc_direct_flag(lbac, bs, core, cu_data->pred_mode[cup] == MODE_DIR);
            }
            if (cu_data->pred_mode[cup] == MODE_DIR) {
                assert(cu_data->pb_part[cup] == SIZE_2Nx2N);
                if (info->sqh.umve_enable) {
                    lbac_enc_umve_flag(lbac, bs, cu_data->umve_flag[cup]);
                }
                if (cu_data->umve_flag[cup]) {
                    lbac_enc_umve_idx(lbac, bs, cu_data->umve_idx[cup]);
                } else {
                    lbac_enc_affine_flag(lbac, bs, core, cur_info->affine_flag != 0);
                    if (cur_info->affine_flag) {
                        lbac_enc_affine_mrg_idx(lbac, bs, cu_data->skip_idx[cup]);
                    } else {
                        lbac_enc_skip_idx(lbac, bs, core->pichdr, cu_data->skip_idx[cup], info->sqh.num_of_hmvp);
                    }
                }
            } else {
                if (core->cons_pred_mode == NO_MODE_CONS) {
                    lbac_enc_pred_mode(lbac, bs, core, cu_data->pred_mode[cup]);
                } else if (core->cons_pred_mode == ONLY_INTER) {
                    assert(cu_data->pred_mode[cup] == MODE_INTER);
                } else {
                    assert(cu_data->pred_mode[cup] == MODE_INTRA);
                }

                if (cu_data->pred_mode[cup] != MODE_INTRA) {
                    assert(cu_data->pred_mode[cup] == MODE_INTER);
                    lbac_enc_affine_flag(lbac, bs, core, cur_info->affine_flag != 0); /* inter affine_flag */

                    if (info->sqh.amvr_enable) {
                        if (info->sqh.emvr_enable && !cur_info->affine_flag) { // also imply info->sqh.num_of_hmvp is not zero
                            lbac_enc_mvr_flag_extend(lbac, bs, cu_data->hmvp_flag[cup]);
                        }
                        lbac_enc_mvr_idx(lbac, bs, cu_data->mvr_idx[cup], cur_info->affine_flag);
                    }
                    if (cu_data->pred_mode[cup] != MODE_DIR) {
                        if (slice_type == SLICE_B) {
                            lbac_enc_inter_dir(lbac, bs, core, cu_data->refi[cup], cur_info->pb_part);
                        }
                        if (cur_info->affine_flag) { // affine inter mode
                            int vertex;
                            int vertex_num = cur_info->affine_flag + 1;
                            int aff_scup[VER_NUM];
                            aff_scup[0] = cup;
                            aff_scup[1] = cup + ((cu_width >> MIN_CU_LOG2) - 1);
                            aff_scup[2] = cup + (((cu_height >> MIN_CU_LOG2) - 1) << info->log2_lcuwh_in_scu);
                            refi0 = cu_data->refi[cup][REFP_0];
                            refi1 = cu_data->refi[cup][REFP_1];
                            if (IS_INTER_SLICE(slice_type) && REFI_IS_VALID(refi0)) {
                                lbac_enc_refi(lbac, bs, core->num_refp[REFP_0], refi0);
                                for (vertex = 0; vertex < vertex_num; vertex++) {
                                    s16 mvd_tmp[MV_D];
                                    u8 amvr_shift = Tab_Affine_AMVR(cu_data->mvr_idx[cup]);
                                    mvd_tmp[MV_X] = cu_data->mvd[aff_scup[vertex]][REFP_0][MV_X] >> amvr_shift;
                                    mvd_tmp[MV_Y] = cu_data->mvd[aff_scup[vertex]][REFP_0][MV_Y] >> amvr_shift;
                                    lbac_enc_mvd(lbac, bs, mvd_tmp);
                                }
                            }
                            if (slice_type == SLICE_B && REFI_IS_VALID(refi1)) {
                                lbac_enc_refi(lbac, bs, core->num_refp[REFP_1], refi1);
                                for (vertex = 0; vertex < vertex_num; vertex++) {
                                    s16 mvd_tmp[MV_D];
                                    u8 amvr_Shift = Tab_Affine_AMVR(cu_data->mvr_idx[cup]);
                                    mvd_tmp[MV_X] = cu_data->mvd[aff_scup[vertex]][REFP_1][MV_X] >> amvr_Shift;
                                    mvd_tmp[MV_Y] = cu_data->mvd[aff_scup[vertex]][REFP_1][MV_Y] >> amvr_Shift;
                                    lbac_enc_mvd(lbac, bs, mvd_tmp);
                                }
                            }
                        } else {
                            refi0 = cu_data->refi[cup][REFP_0];
                            refi1 = cu_data->refi[cup][REFP_1];

                            if (info->sqh.smvd_enable && REFI_IS_VALID(refi0) && REFI_IS_VALID(refi1)
                                && (core->ptr - core->refp[0][REFP_0].ptr == core->refp[0][REFP_1].ptr - core->ptr)
                                && !cu_data->hmvp_flag[cup]
                               ) {
                                lbac_enc_smvd_flag(lbac, bs, cu_data->smvd_flag[cup]);
                            }

                            if (IS_INTER_SLICE(slice_type) && REFI_IS_VALID(refi0)) {
                                if (cu_data->smvd_flag[cup] == 0) {
                                    lbac_enc_refi(lbac, bs, core->num_refp[REFP_0], refi0);
                                }

                                cu_data->mvd[cup][REFP_0][MV_Y] >>= cu_data->mvr_idx[cup];
                                cu_data->mvd[cup][REFP_0][MV_X] >>= cu_data->mvr_idx[cup];
                                lbac_enc_mvd(lbac, bs, cu_data->mvd[cup][REFP_0]);
                                cu_data->mvd[cup][REFP_0][MV_Y] <<= cu_data->mvr_idx[cup];
                                cu_data->mvd[cup][REFP_0][MV_X] <<= cu_data->mvr_idx[cup];
                            }
                            if (slice_type == SLICE_B && REFI_IS_VALID(refi1)) {
                                if (cu_data->smvd_flag[cup] == 0) {
                                    lbac_enc_refi(lbac, bs, core->num_refp[REFP_1], refi1);
                                    cu_data->mvd[cup][REFP_1][MV_Y] >>= cu_data->mvr_idx[cup];
                                    cu_data->mvd[cup][REFP_1][MV_X] >>= cu_data->mvr_idx[cup];
                                    lbac_enc_mvd(lbac, bs, cu_data->mvd[cup][REFP_1]);
                                    cu_data->mvd[cup][REFP_1][MV_Y] <<= cu_data->mvr_idx[cup];
                                    cu_data->mvd[cup][REFP_1][MV_X] <<= cu_data->mvr_idx[cup];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (cu_data->pred_mode[cup] == MODE_INTRA) {
        if (core->tree_status != TREE_C) {
            com_assert(cu_data->ipm_l[cup] != IPD_INVALID);
        }
        if (core->tree_status != TREE_L) {
            com_assert(cu_data->ipm_c[cup] != IPD_INVALID);
        }
        lbac_enc_part_size(lbac, bs, core, cu_data->pb_part[cup], cu_width, cu_height, cu_data->pred_mode[cup]);
        get_part_info(info->max_cuwh >> 2, x % info->max_cuwh, y % info->max_cuwh, cu_width, cu_height, cu_data->pb_part[cup], &cur_info->pb_info);
        assert(cur_info->pb_info.sub_scup[0] == cup);

        for (int part_idx = 0; part_idx < cur_info->pb_info.num_sub_part; part_idx++) {
            int pb_x      = cur_info->pb_info.sub_x[part_idx];
            int pb_y      = cur_info->pb_info.sub_y[part_idx];
            int pb_width  = cur_info->pb_info.sub_w[part_idx];
            int pb_height = cur_info->pb_info.sub_h[part_idx];
            int pb_scup   = cur_info->pb_info.sub_scup[part_idx];

            cur_info->ipm[part_idx][0] = cu_data->ipm_l[pb_scup];

            lbac_enc_intra_dir(lbac, bs, cu_data->ipm_l[pb_scup], cu_data->mpm[pb_scup]);

        }
        if (core->tree_status != TREE_L) {
            cur_info->ipm[PB0][1] = cu_data->ipm_c[cup];
            lbac_enc_intra_dir_c(lbac, bs, cu_data->ipm_c[cup], cu_data->ipm_l[cup], info->sqh.tscpm_enable);
        }

        if (!((core->tree_status == TREE_C && cu_data->ipm_l[cup] == IPD_IPCM && cu_data->ipm_c[cup] == IPD_DM_C)
              || (core->tree_status != TREE_C && cu_data->ipm_l[cup] == IPD_IPCM))) {

#if DT_INTRA_BOUNDARY_FILTER_OFF
            if (info->sqh.ipf_enable_flag && (cu_width < MAX_CU_SIZE) && (cu_height < MAX_CU_SIZE) && cur_info->pb_part == SIZE_2Nx2N)
#else
            if (info->sqh.ipf_enable_flag && (cu_width < MAX_CU_SIZE) && (cu_height < MAX_CU_SIZE))
#endif
                lbac_enc_ipf_flag(lbac, bs, cu_data->ipf_flag[cup]);
        }
    }

    if (!core->skip_flag) {
        lbac_enc_coef(lbac, bs, core, coef, core->cu_width_log2, core->cu_height_log2, cu_data->pred_mode[cup], cur_info, core->tree_status);
    }

    map_scu = map->map_scu + core->cu_scup_in_pic;
    map_pos = map->map_pos + core->cu_scup_in_pic;

    if (core->tree_status == TREE_LC) {
        cu_cbf_flag = is_cu_nz(cur_info->num_nz);
    } else if (core->tree_status == TREE_L) {
        cu_cbf_flag = is_cu_plane_nz(cur_info->num_nz, Y_C);
    } else {
        assert(0);
    }
    w = (core->cu_width  >> MIN_CU_LOG2);
    h = (core->cu_height >> MIN_CU_LOG2);

    com_scu_t scu = map_scu[0];
    scu.coded = 1;

    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            assert(map_scu[j].skip == core->skip_flag);
            assert(map_scu[j].cbf == cu_cbf_flag);
            assert(map_scu[j].affine == cur_info->affine_flag);
            assert(map_scu[j].tbpart == cur_info->tb_part);
            assert(map_scu[j].intra == cu_data->pred_mode[cup] == MODE_INTRA);
            assert(MCU_GET_SCUP(map_pos[j]) == core->cu_scup_in_pic);
            assert(MCU_GET_LOGW(map_pos[j]) == core->cu_width_log2);
            assert(MCU_GET_LOGH(map_pos[j]) == core->cu_height_log2);

            map_scu[j] = scu;
        }
        map_scu += info->i_scu;
        map_pos += info->i_scu;
    }

    return COM_OK;
}

void lbac_enc_sao_mrg_flag(lbac_t *lbac, bs_t *bs, int mergeleft_avail, int mergeup_avail, com_sao_param_t *saoBlkParam)
{
    int MergeLeft = 0;
    int MergeUp   = 0;
    int value1    = 0;
    int value2    = 0;

    if (mergeleft_avail) {
        MergeLeft = (saoBlkParam->modeIdc == SAO_MODE_MERGE_LEFT);
        value1 = MergeLeft ? 1 : 0;
    }
    if (mergeup_avail && !MergeLeft) {
        MergeUp = (saoBlkParam->modeIdc == SAO_MODE_MERGE_ABOVE);
        value1 = MergeUp ? (1 + mergeleft_avail) : 0;
    }
    value2 = mergeleft_avail + mergeup_avail;
    if (value2 == 1) {
        assert(value1 <= 1);
        lbac_encode_bin(value1, lbac, &lbac->h.sao_merge_flag[0], bs);
    } else if (value2 == 2) {
        assert(value1 <= 2);
        lbac_encode_bin(value1 & 0x01, lbac, &lbac->h.sao_merge_flag[1], bs);
        if (value1 != 1) {
            lbac_encode_bin((value1 >> 1) & 0x01, lbac, &lbac->h.sao_merge_flag[2], bs);
        }
    }
}

void lbac_enc_sao_mode(lbac_t *lbac, bs_t *bs, com_sao_param_t *saoBlkParam)
{
    if (saoBlkParam->typeIdc == -1) {
        lbac_encode_bin(1, lbac, lbac->h.sao_mode, bs);
    } else if (saoBlkParam->typeIdc == SAO_TYPE_BO) {
        lbac_encode_bin(0, lbac, lbac->h.sao_mode, bs);
        lbac_encode_bin_ep(1, lbac, bs);
    } else {
        lbac_encode_bin(0, lbac, lbac->h.sao_mode, bs);
        lbac_encode_bin_ep(0, lbac, bs);
    }
    
}

static void sao_one_offset(int value1, int offset_type, lbac_t *lbac, bs_t *bs)
{
    int act_sym;
  
    if (offset_type == SAO_CLASS_EO_FULL_VALLEY) {
        act_sym = tbl_sao_eo_offset_map[value1 + 1];
    } else if (offset_type == SAO_CLASS_EO_FULL_PEAK) {
        act_sym = tbl_sao_eo_offset_map[-value1 + 1];
    } else {
        act_sym = abs(value1);
    }
    if (act_sym == 0) {
        if (offset_type == SAO_CLASS_BO) {
            lbac_encode_bin(1, lbac, lbac->h.sao_offset, bs);
        } else {
            lbac_encode_bin_ep(1, lbac, bs);
        }
    } else {
        int temp = act_sym;

        while (temp) {
            if (offset_type == SAO_CLASS_BO && temp == act_sym) {
                lbac_encode_bin(0, lbac, lbac->h.sao_offset, bs);
            } else {
                lbac_encode_bin_ep(0, lbac, bs);
            }
            temp--;
        }
        if (act_sym < tbl_sao_bound_clip[offset_type][2]) {
            lbac_encode_bin_ep(1, lbac, bs);
        }
        if (offset_type == SAO_CLASS_BO) {
            lbac_encode_bin_ep(value1 < 0, lbac, bs);
        }
    }
}

void lbac_enc_sao_offset(lbac_t *lbac, bs_t *bs, com_sao_param_t *saoBlkParam)
{
    if (saoBlkParam->typeIdc == SAO_TYPE_BO) {
        for (int i = 0; i < 4; i++) {
            sao_one_offset(saoBlkParam->offset[i], SAO_CLASS_BO, lbac, bs);
        }
    } else {
        for (int i = SAO_CLASS_EO_FULL_VALLEY; i < NUM_SAO_EO_CLASSES; i++) {
            if (i == SAO_CLASS_EO_PLAIN) {
                continue;
            }
            sao_one_offset(saoBlkParam->offset[i], i, lbac, bs);
        }
    }
}

static void sao_band_and_type(int value1, int value2, lbac_t *lbac, bs_t *bs)
{
    if (value2 == 2) { //Delta for BO
        int exp_golomb_order = 1;
        int act_sym = value1;
        int temp = value1;

        while (1) {
            if ((unsigned int)temp >= (unsigned int)(1 << exp_golomb_order)) {
                lbac_encode_bin_ep(0, lbac, bs);
                temp = temp - (1 << exp_golomb_order);
                exp_golomb_order++;
            } else {
                if (exp_golomb_order == 4) {
                    exp_golomb_order = 0;
                } else {
                    lbac_encode_bin_ep(1, lbac, bs);
                }
                while (exp_golomb_order--) {   //next binary part
                    lbac_encode_bin_ep((unsigned char)((temp >> exp_golomb_order) & 1), lbac, bs);
                }
                break;
            }
        }
    } else {
        int length = value2 ? NUM_SAO_BO_CLASSES_LOG2 : NUM_SAO_EO_TYPES_LOG2;

        for (int i = 0; i < length; i++) {
            lbac_encode_bin_ep(value1 & 1, lbac, bs);
            value1 >>= 1;
        }
    }
}

void lbac_enc_sao_type(lbac_t *lbac, bs_t *bs, com_sao_param_t *saoBlkParam)
{
    int value1 = 0;
    int value2 = 0;

    if (saoBlkParam->typeIdc == SAO_TYPE_BO) {
        value1 = saoBlkParam->bandIdx[0];
        value2 = 1;//write start band for BO
        sao_band_and_type(value1, value2, lbac, bs);
        assert(saoBlkParam->deltaband >= 2);
        value1 = saoBlkParam->deltaband - 2;
        value2 = 2;//write delta start band for BO
        sao_band_and_type(value1, value2, lbac, bs);
    } else {
        assert(saoBlkParam->typeIdc >= SAO_TYPE_EO_0 && saoBlkParam->typeIdc <= SAO_TYPE_EO_45);
        value1 = saoBlkParam->typeIdc;
        value2 = 0;
        sao_band_and_type(value1, value2, lbac, bs);
    }
}

void lbac_enc_sao_param(lbac_t *lbac, bs_t *bs, com_patch_header_t *pathdr, com_map_t *map, com_info_t *info, int lcu_y, int lcu_x, com_sao_param_t sao_cur_param[N_C], com_sao_param_t(*sao_blk_params_map)[N_C])
{
    int lcu_pos = lcu_y * info->pic_width_in_lcu + lcu_x;

    if (!pathdr->slice_sao_enable[Y_C] && !pathdr->slice_sao_enable[U_C] && !pathdr->slice_sao_enable[V_C]) {
        return;
    }

    int scu_x = lcu_x << (info->log2_max_cuwh - MIN_CU_LOG2);
    int scu_y = lcu_y << (info->log2_max_cuwh - MIN_CU_LOG2);
    com_sao_param_t merge_candidate[NUM_SAO_MERGE_TYPES][N_C];
    int merge_avail[NUM_SAO_MERGE_TYPES];

    getSaoMergeNeighbor(info, map->map_patch, info->pic_width_in_scu, info->pic_width_in_lcu, lcu_pos, scu_y, scu_x, sao_blk_params_map, merge_avail, merge_candidate);

    int MergeLeftAvail = merge_avail[SAO_MERGE_LEFT];
    int MergeUpAvail = merge_avail[SAO_MERGE_ABOVE];

    if (MergeLeftAvail + MergeUpAvail) {
        lbac_enc_sao_mrg_flag(lbac, bs, MergeLeftAvail, MergeUpAvail, &(sao_cur_param[Y_C]));
    }
    if (sao_cur_param[Y_C].modeIdc == SAO_MODE_NEW) {
        //luma
        if (pathdr->slice_sao_enable[Y_C] == 1) {
            lbac_enc_sao_mode(lbac, bs, &(sao_cur_param[Y_C]));
            if (sao_cur_param[Y_C].typeIdc != -1) {
                lbac_enc_sao_offset(lbac, bs, &(sao_cur_param[Y_C]));
                lbac_enc_sao_type(lbac, bs, &(sao_cur_param[Y_C]));
            }
        }
        for (int compIdx = U_C; compIdx < N_C; compIdx++) {
            if (pathdr->slice_sao_enable[compIdx] == 1) {
                lbac_enc_sao_mode(lbac, bs, &(sao_cur_param[compIdx]));
                if (sao_cur_param[compIdx].typeIdc != -1) {
                    lbac_enc_sao_offset(lbac, bs, &(sao_cur_param[compIdx]));
                    lbac_enc_sao_type(lbac, bs, &(sao_cur_param[compIdx]));
                }
            }
        }
    }
}


void lbac_enc_alf_flag(lbac_t *lbac, bs_t *bs, int iflag)
{
    lbac_encode_bin(iflag, lbac, lbac->h.alf_lcu_enable, bs);
}

void lbac_enc_lcu_delta_qp(lbac_t *lbac, bs_t *bs, int val, int last_dqp)
{
    com_lbac_all_ctx_t *lbac_ctx = &lbac->h;
    int act_sym;
    int act_ctx = ((last_dqp != 0) ? 1 : 0);

    if (val > 0) {
        act_sym = 2 * val - 1;
    } else {
        act_sym = -2 * val;
    }

    if (act_sym == 0) {
        lbac_encode_bin(1, lbac, lbac_ctx->lcu_qp_delta + act_ctx, bs);
    } else {
        lbac_encode_bin(0, lbac, lbac_ctx->lcu_qp_delta + act_ctx, bs);
        act_ctx = 2;
        if (act_sym == 1) {
            lbac_encode_bin(1, lbac, lbac_ctx->lcu_qp_delta + act_ctx, bs);
        } else {
            lbac_encode_bin(0, lbac, lbac_ctx->lcu_qp_delta + act_ctx, bs);
            act_ctx++;
            while (act_sym > 2) {
                lbac_encode_bin(0, lbac, lbac_ctx->lcu_qp_delta + act_ctx, bs);
                act_sym--;
            }
            lbac_encode_bin(1, lbac, lbac_ctx->lcu_qp_delta + act_ctx, bs);
        }
    }
}

static int ec_write_seq_display_extension(bs_t *bs, int colour_primaries, int transfer_characteristics)
{
    bs_write(bs, 2, 4);                            // extension_id                 f(4)
    bs_write(bs, 0, 3);                            // video_format                 u(3)
    bs_write1(bs, 0);                              // sample_range                 u(1)
    bs_write1(bs, 1);                              // colour_description           u(1)
    bs_write(bs, colour_primaries, 8);             // colour_primaries             u(8)
    bs_write(bs, transfer_characteristics, 8);     // transfer_characteristics     u(8)
    printf("colour_primaries = %d\n", colour_primaries);
    printf("transfer_characteristics = %d\n", transfer_characteristics);
    bs_write(bs, 1, 8);                            // matrix_coefficients          u(8)

    bs_write(bs, 8, 14);                           // display_horizontal_size      u(14)
    bs_write1(bs, 1);                              // marker_bit                   f(1)
    bs_write(bs, 8, 14);                           // display_vertical_size        u(14)
    bs_write1(bs, 1);                              // td_mode_flag                 u(1)
    bs_write(bs, 1, 8);                            // td_packing_mode              u(8)
    bs_write1(bs, 0);                              // view_reverse_flag            u(1)

    bs_write1(bs, 1);                              // stuffing bit
    while (!IS_BYTE_ALIGN(bs)) {
        bs_write1(bs, 0);
    }
    return 0;
}

static int enc_extension_data(bs_t *bs, int i, int slice_type)
{
    int colour_primaries = 1;
    int transfer_characteristics = 1;

    bs_write(bs, 0x1, 24);
    bs_write(bs, 0xB5, 8);

    ec_write_seq_display_extension(bs, colour_primaries, transfer_characteristics);

    return 0;
}

int ec_write_ext_and_usr_data(bs_t *bs, int signature, com_pic_t *pic_rec, int i, int slice_type, u8 isExtension)
{
    if (isExtension) {
        enc_extension_data(bs, i, slice_type);
    } else {
        bs_write(bs, 0x1, 24);
        bs_write(bs, 0xB2, 8);

        /* picture signature */
        if (signature) {
            u8 pic_sign[16];
    
            com_md5_img(pic_rec->img, pic_sign);
       
            /* write user data type */
            bs_write(bs, COM_UD_PIC_SIGNATURE, 8);
       
            for (int i = 0; i < 16; i++) {
                bs_write(bs, pic_sign[i], 8);
                if (i % 2 == 1) {
                    bs_write1(bs, 1);
                }
            }
        }
        bs_write(bs, COM_UD_END, 8);
    }

    return 0;
}


